Hibernate Advantages and Disadvantages

  • Facebook
  • Google
  • LinkedIn
  • Twitter

Hibernate Advantages

  • Hibernate is free and open source framework
  • Programmers need to write code in JDBC to map an object model`s data representation to a relational data model and its corresponding database schema. Hibernate provides a mechanism to maps Java classes to database tables and from Java data types to SQL data types so programmers no need to write code for this.
  • Hibernate provided Dialect classes for the different database, so you no need to write SQL queries in hibernate
  • Hibernate is Database independent framework and it has HQL (Hibernate Query Language) which is database independent it means you no need to write code specific to database.
  • There is no more knowledge required of SQL is needed for working with hibernate.
  • Hibernate do query tuning by using Criteria queries itself and not required to do extra work for it.
  • Hibernate supports Inheritance so that you save the derived class object and its base class object will also be saved into the database.
  • Hibernate support cache, so data can be placed in the cache for better performance. Where as in JDBC java cache is need to be implemented.
  • Hibernate supports by default first level cache so it reduces the number of round trips between application and database.
  • Hibernate supports a variety of relational database like One-To-One, One-To-Many, Many-To-One, Many-To-Many.
  • Hibernate has capability to generate primary keys automatically while we are storing the records into database.
  • Hibernate provides Productivity, Maintainability, Portability.
  • Hibernate supports Collections like List,Set,Map
  • You need to catch all exceptions in JDBC i.e checked exceptions, so you must write code in try, catch and throws, but in hibernate you no need to write code in try and catch block for it and all exceptions are Un-checked exceptions

Hibernate Disadvantages

  • If it is a small project with few tables, so I think there is no need for ORM framework like hibernate In such case a normal JDBC is enough.
  • Hibernate has a performance cost as it adds a layer over jdbc. Also with Hibernate lot of table configuration information (hbm or annotations) is read at start up adding to the start up time of your application.
  • Hibernate is not suitable for Batch processing you have to use pure JDBC for batch processing.
  • Hibernate is slow because it uses run time reflection but Modern JVMs implement reflection extremely efficiently In the very latest versions of Hibernate, “reflection” is optimized via the CGLIB runtime bytecode generation library. You can use native sql if it is going to be complex scenarios.