Advantages and Disadvantages of using Hibernate like ORM libraries
Traditionally Programmers used ODBC, JDBC, ADO etc to access database. Developers need to write SQL queries, process the result set and convert the data in the form of objects (Data model). I think most programmers would typically write a function to convert the object to query and result set to object. To overcome these difficulties, ORM provides a mechanism to directly use objects and interact with the database.
There are lots of advantages of using ORM
- Database independent. This is the biggest advantage. No need to write code specific to database. I have worked in various products where they maintain separate module / code base for every database and there is lot of effort invested to support multiple database. ORM is a boon.
- There is no need to write SQL queries. Session.saveOrUpdate(entityObject) takes care of insertion in case of Hibernate.
- Takes care of dependencies between tables and does join queries.
- Few ORM libraries has support of caching. Hibernate uses ehcache and provides caching support. This reduces the load from the database and increases the response time.
- Maintains transactions commit and rollback.
- Maintains database connection pool.
- Concurrency support.
- Easy maintenance and increases productivity.
- ORM makes life easier but developers will eventually skip learning SQL and database internals.
- There will be some overhead involved using ORM. If the database is accessed directly then developers are having some control and they could fine tune its performance.
- There is a learning curve involved in understanding ORM library. Java, .NET, PHP has better ORM libraries. .NET has support of LINQ, which is a Framework that encompass language-integrated query.
If your project is using single database and you may need to run some complex queries and fine tune the performance then choose ODBC, JDBC, ADO or similar kind of Data access layers. If not choose ORM as it will make your life easier. But spend some time in understanding the database internals as it will help to take leverage of both ends.
Open source ORM libraries
Open source database
Open source connection pool libraries in Java