JAVA: Understanding Hibernate

Hibernate is an open source ORM (Object Relational Mapping) type solution which facilitates the development of the persistence layer of an application. Hibernate therefore allows you to represent a database in Java objects and vice versa.

What is ORM ?

Object-Relational Mapping (ORM) is a technique that lets you query and manipulate data from a database using an object-oriented paradigm.

from www.javaguides.net

The Configuration to use Hibernate

from www.jmdoudoux.fr

Example:

from www.jmdoudoux.fr

The use of Hibernate

To use Hibernate in the code, it is necessary to perform several operations:

1. creating an instance of the class
2. creating an instance of the SessionFactory class
3. creation of an instance of the Session class which will allow you to use Hibernate services.

Storing data

if we want to store an object of a Person class in a database :

  1. first thing to do is adding @Entity to the class.
  2. write this code after the previous in the main class.

Fetching data

Computer science Engineer Student, A lover of everything that urges the mind to work hard such as Quantum Physics, General Medicine, Personal dev…

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Reflections: Web Scraper CLI Application with Ruby

Want to succeed with Digital Internal Audit? The answer fits in your pocket.

Knowledge Management Software Overview 2021

How To Write A Stellar Tech Resume That Gets You More Job Opportunities

Everything you need to know about MacBook Pros and (their lack of) DisplayPort MST (Multi-Stream)…

The Most Wanted Commands in Pyspark (Demo in Databricks)

AGILE DEVELOPMENT FOR ZOMATO PRODUCT FEATURES

How the classes and objects work in Python?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ELMASLOUHY Mouaad

ELMASLOUHY Mouaad

Computer science Engineer Student, A lover of everything that urges the mind to work hard such as Quantum Physics, General Medicine, Personal dev…

More from Medium

JAVA 8 vs JAVA

Avoiding NullPointerException In Java

Collection framework| java

Java, reference variable