Overview, Architecture and Configuration
Hibernate is the framework written in Java which helps to connect with database.
Hibernate allows us to perform multiple operations such as create, insert, delete data in database.
Hibernate is an open source, light weight ORM (Object Relational Mapping) tool. It allows us to map Java bean/Pojo objects with database table.
ORM (Object Relational Mapping) tool helps us create a mapping in between Java persistence object and database table.
As mentioned above, Hibernate is all about four core modules such as Java application, persistence object, Hibernate and database.
Java application: This will be using Hibernate to perform all operations.
Object: Also called as persistence object in which we store a data.
Hibernate: Using Hibernate mapping and configuration we create a relation in between Hibernate and Object.
Database: Use to store data with the help of object.
At the time of project compilation, Hibernate has a capability to create database and tables using script.
Hibernate Architecture
Hibernate is based layered architecture. Hibernate uses Java API’s like JDBC (Java Database connectivity), Java Transaction API (JTA) and Java Naming and Directory Interface (JNDI) to save data in database.
Hibernate with MySQL Dependencies
Hibernate uses the below pom dependencies for Hibernate Java applications:
Hibernate Configurations
There are two main configuration files to work with the Hibernate framework:
- <class>.hbm.xml: This configuration file will be having a mapping of class and table along with variables and columns.
2. hibernate.cfg.xml: This configuration file will help us to create a connection with database and map bean class using <class>.hbm.xml
This article is just an overview of Hibernate framework. We will be having a detailed discussion on above configurations in next article.
Overall Hibernate Mapping
Below is the over all mapping strategy required for hibernate project in between class, MySQL table and hibernate configuration.
- Create a User bean class and its getter setter methods.
- Create user.hbml.xml to create mapping in between class and MySQL table.
- Create hibernate.cfg.xml configuration file for database connection and include user hbm xml mapping file.
- create a database and table to insert data in MySQL database.
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.