In this post I’ll discuss why Hibernate and what it gives.
It makes your development easy and more productive. As I discussed in my previous post, it maps your objects (POJO) with relational database. This automatic mapping of java object to database and vice versa is called Transparent Persistence. And this will reduce lot of coding from your program and also reduce the potential number of errors.
Hibernate lets you to change your database without doing any change to your program. For an example you can change your MySQL database to Oracle by just changing dialect of Hibernate configuration file to Oracle. So your application is database independent.
With Hibernate you don’t need to write messy SQl queries. Instead you can write object queries (HQL) and Hibernate will do rest for you.
Hibernate is provides you automatic versioning and time stamping. By using this, you can ensure that the changers done by one person to the database will not rollback by another user unintentionally. To enable this you need to define version type field in your application. Every time you modify particular record of database, Hibernate updates this version. Hibernate always check this version when you save data. So Hibernate is not allowing you to update particular record with older version of it.
Optimize performance. Hibernate is cache querying data in application workspace. So it improves the performance if application reads same data many times for same write.