Hibernate(framework)

Techno Freak
2 min readAug 1, 2022

--

Mapping from Java classes to database tables and vice versa

Hibernate is the famous object-mapping tool for Java programming language. Hibernate also provides data query and retrieval facilities. It generates SQL calls and relieves the developer from the manual handling and object conversion of the result set.

Basic Prerequisite

Very good understanding of Java Programming Language. Basics of RDBMS(Relational Database Management System),JDBC(Java Database Connectivity) and SQL (Structured Query Language).

Hibernate Architecture

As you all can the below image which gives you a basic idea . It has a layered architecture which helps the end-user to work efficiently without knowing about the underlying APIs and functionality.

  1. Persistent Object:
    Persistent objects are instances of POJO classes that you create that represent rows in the table in the database. According to hibernate-doc(official Documentation)an instance of POJO class representing table in database goes through 3 states of which persistent is one of them.

2.Configuration Object: Persistent objects are instances of POJO classes that you create that represent rows in the table in the database. According to hibernate-doc(official Documentation)an instance of POJO class representing table in database goes through 3 states of which persistent is one of them.

3. Session Factory Object : The Session Factory is a heavyweight object; it is usually created during application start up and kept for later use. You would need one Session Factory object per database using a separate configuration file. So, if you are using multiple databases, then you would have to create multiple Session Factory objects.

4.Transaction Object: Transaction represents a unit of work with the database and most of the RDBMS supports transaction functionality. Transactions in Hibernate are handled by an underlying transaction manager and transaction (from JDBC or JTA).This is an optional object and Hibernate applications may choose not to use this interface, instead managing transactions in their own application code.

5.Query Object: Query objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects

6.Criteria Object: Criteria objects are used to create and execute object oriented criteria queries to retrieve objects.

What's the need of Hibernate ..

  • Hibernate overcomes the object level relationship.
  • It reduces the length of code with increased readability by overcoming the boiler plate problem.
  • Helps to overcome Exceptional Handling(mandatory for working of JDBC).
  • Helps to overcome database dependency.
  • Increased Performance.

Online Courses to Learn Hibernate for Java Developers

  1. Introduction to Hibernate by John Sönmez
  2. Hibernate Fundamentals: Hands-On Primer With Java EE and JPA
  3. Master Hibernate and JPA With Spring Boot in 100 Steps
  4. Hibernate and Java Persistence API (JPA) Fundamentals
  5. Java Persistence: Hibernate and JPA Fundamentals

Do check out the content on Hibernate Follow back for more such content . Happy exploring .

--

--

Techno Freak
Techno Freak

Written by Techno Freak

Devops &Full-Stack enthusiast . Helping People to learn about cloud and opensource . Learning bit by bit

No responses yet