Hibernate in Java is framework used for developing the data access layer in Java based applications.
Hibernate is an open-source ORM solution for Java applications.Hibernate framework simplifies the
development of java application to interact with the database. Hibernate is an open source,
lightweight, ORM (Object Relational Mapping) tool.
An ORM tool simplifies the data creation, data manipulation and data access.
It is a programming technique that maps the object to the data stored in the database.
Why Object Relational Mapping (ORM)?
When we work with an object-oriented systems, there's a mismatch between the object model
and the relationaldatabase. RDBMSs represent data in a tabular format whereas object-oriented languages,
such as Java or C# represent it as an interconnected graph of objects. Consider the following Java Class
with proper constructors and associated public function.
What is ORM?
ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data between
relational databases and object oriented programming languages such as Java, C# etc. An ORM system has
following advantages over plain JDBC
Advantages of Hibernate Framework
There are many advantages of Hibernate Framework. They are as follows:
Opensource and Lightweight: Hibernate framework is opensource under the LGPL license and lightweight.
Fast performance: The performance of hibernate framework is fast because cache is internally used in hibernate framework.
There are two types of cache in hibernate framework first level cache and second level cache.
First level cache is enabled bydefault.
Database Independent query: HQL (Hibernate Query Language) is the object-oriented version of SQL. It generates the database independent queries. So you don't need to write database specific queries. Before Hibernate,
If database is changed for the project, we need to change the SQL query as well that leads to the maintenance problem.
Automatic table creation: Hibernate framework provides the facility to create the tables of the database automatically.
So there is no need to create tables in the database manually.
Simplifies complex join: To fetch data form multiple tables is easy in hibernate framework.
Provides query statistics and database status: Hibernate supports Query cache and provide statistics about query and database status.
No need to deal with the database implementation.
Entities based on business concepts rather than database structure.
Transaction management and automatic key generation.
Fast development of application