Introduction to HibernateIntroduction to hibernate will help you to understand what is ORM / Hibernate. Working in rapid application development with Object Oriented and Relational Database is very time consuming and sometimes it becomes difficult to manage relation between Objects and relational databases. And sometimes development costs become higher due to maintenance. Hibernate is an ORM (Object relational Mapping) tool which is free to download and use under GNU and LGPL license. Hibernate is an solution which provides us great control over Objects and Relational database.
What is ORM
ORM (Object Relational Mapping) is a technique in which object model (Normally Java POJO classes) is mapped to relational data model (which is database tables) and visa vera. Hibernate is not just mapping the Objects to Relational Database and visa versa but It also providing you the facilities to query data and different ways to retrieve. Which reduces the development time and maintenance because it reduces the effort for handling JDBC and SQL related work.
Advantages of using Hibernate
- Allows you to map plain Java Object to relational database and visa vera.
- Provides you great identifier generators.
- Support first level and second level cache to increase response rate.
- Hibernate is not vender spadicifc, you can use any database like MySql, Oracle, SQL server etc.
- Once you map Objects with Relational Database, you will have advantages of OOps concepts like Inheritance, encapsulation etc.
- Lazy loading, In case of parent class have multiple child objects. You can control to load child objects or not if you don’t need them.
- Comes up with it’s own query language HQL which is not depend on any vender. So if you switch to different database then you don’t need to change your query langauge.
- Hibernate supports relational mapping like One-To-Many, One-To-One, Many-To-Many, Many-To-One.
- Hibernate also supports different types of collections like List,Set,Map.
- In Hibernate, you don’t need to handle exceptions manually. Framework takes care of them because in Hibernate we only have Un-checked exceptions.
- Hibernate supports XML as well as annotation based configuration.