Hibernate is an ORM model framework for applications to interact with the databases.
Where ORM stands for Object Relational Mapping.
Because of ORM it maps the java object oriented domain model to the relational database.
Hibernate Current stable version is 5.4 compatible with java 11 and JPA 2.2 released in Dec 2019, next version 6 is in development phase.
Hibernate’s Primary features :
- Map Java POJO class to Database table
- Map Java Data types to SQL table data types
- Query data using HQL
- Unlike jdbc, need not create Resultset, it handles it automatically
Mapping
What is mapping ? – The mapping of JAVA POJO classes with the database tables is called the mapping.
How is it done ? – It is done either in xml config files or via annotations which is of course the new and simpler way of mapping.
Types of mapping ? – Mapping in JPA is of many types like, one-to-one, one-to-many, many-to-one, many-to-many and all these mapping can be done via annotations in java pojo classes and internally being handled by hibernate.
HQL – Hibernate Query Language
Hibernate query language is the object oriented version of SQL. It enables a developer to write database independent queries and hence there is no need to write database specific queries. Read more about HQL here.
Persistence
Hibernate provides simple and easy ways to persist POJO(plain old java objects). Hibernate has different loading ways like Lazy loading and Eager loading. It also has many propagation levels, meaning cascading of operations from one object to the other. Read more about cascading operations here.
Entity
An entity is a standalone object in Hibernate persistent mechanism. It is also a representation of a database table in the form of a POJO class. Read more about entities here.
Integration with Java and other frameworks
Hibernate can be configured and used both with Java and J2EE applications using servlets and other components. It can be easily integrated with Spring framework as well.
Summary
In this article, we learnt about Hibernate, we answered what is hibernate and its features. We read about Mapping, Persistence and Entity in hibernate and also about its integration with Java and J2EE applications.
Hope you liked it !