Core Interfaces and Classes

In this blog, we will be having a discussion over the 80% used Hibernate interfaces and classes, which will provide an overview of all Java code used in the Hibernate framework to get data.

Below is the code snippet Hibernate uses to select, insert and update data in database.

Let’s discuss about each and everything line by line.

Configuration

Configuration class is provided by org.hibernate.cfg package. It loads Hibernate configuration only once at the time of project initialization only.

Configuration class is use to load the hibernate configurations from hibernate.cfg.xml

ServiceRegistry

ServiceRegistry is an interface belongs to org.hibernate.service interface.

SessionFactory

SessionFactory is an interface belongs to org.hibernate package. SessionFactory instance helps us to create session.

Session

Session is also an interface belongs to org.hibernate package. Session is responsible for hibernate operations.

Transaction

Again, it is an interface belongs to org.hibernate package which use to perform action such as insert and update data in database.

HQL Query

It is similar to SQL query based or OOPs concept. HQL queries translated by Hibernate into SQL queries, which performs insert, update, delete and other database operations.

Below is the simple HQL example:

HCQL (Hibernate Criteria Query Language )

Hibernate allows us to get data based on specific criteria or in lay man term we can filters.

Criteria is an interface which belongs to org.hibernate package. Criteria can be added using add() method.

Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.

0