Advantage And Disadvantages Of Hibernate ORM
As we know, Hibernate provides a number of predefined methods to solve the complex code. The major advantages & disadvantages are below.
Advantages of hibernates:
- Hibernate supports Inheritance, Associations, Collections
- In hibernate if we save the derived class object, then its base class object will also be stored into the database, it means hibernate supporting inheritance
- Hibernate supports relationships like One-To-Many, One-To-One, Many-To-Many-to-Many, Many-To-One
- This will also support collections like List, Set, Map (Only new collections)
- In JDBC all exceptions are checked exceptions, so we must write code in the try, catch and throws, but in hibernate we only have Un-checked exceptions, so no need to write try, catch, or no need to write throws. Actually, in hibernate, we have the translator which converts checked to Un-checked
- Hibernate can generate primary keys automatically while we are storing the records into the database
- Hibernate has its query language, i.e hibernate query language which is database independent
- So if we change the database, then also our application will works as HQL is database independent
- HQL contains database-independent commands
- While we are inserting any record, if we don’t have any particular table in the database, JDBC will raise an error like “View not exist”, and throws an exception, but in case of hibernating, if it does not find any table in the database this will create the table for us
- Hibernate supports a caching mechanism by this, the number of round trips between an application and the database will be reduced, by using this caching technique an application performance will be increased automatically.
- Hibernate supports annotations, apart from XML
- Hibernate provided Dialect classes, so we no need to write SQL queries in hibernate, instead we use the methods provided by that API.
- Getting pagination in hibernate is quite simple.
As we know the hibernate orm provides several facilities like ready-made methods & classes. Let us see what are the advantages and disadvantages of the hibernate framework
Disadvantages of hibernates
- You know something.., it is saying hibernate is little slower than pure JDBC the reason being hibernate used to generate many SQL statements in run time, but I guess this is not the disadvantage
- But there is one major disadvantage, which was boilerplate code issue we need to write some code in several files in the same application, but spring eliminated this
post a comment