Hibernate - What is the advantage of Hibernate over jdbc?

What is the advantage of Hibernate over jdbc?

- The advantages of Hibernate over JDBC are:

1. Hibernate code will work well for all databases, for ex: Oracle,MySQL, etc. where as JDBC is database specific.

2. No knowledge of SQL is needed because Hibernate is a set of objects and a table is treated as an object, where as to work with JDBC, one need to know SQL.

3. Query tuning is not required in Hibernate. The query tuning is automatic in hibernate by using criteria queries, and the result of performance is at its best. Where as in JDBC the query tuning is to be done by the database authors.

4. With the support of cache of hibernate, the data can be placed in the cache for better performance. Where as in JDBC the java cache is to be implemented.

What is the advantage of Hibernate over jdbc?

1. Developer has to write code in JDBC to map an object model's data representation to a relational data model and its corresponding database schema.

2. Hibernate itself takes care of this mapping using XML files so developer does not need to write code for this.
JDBC supports only native Structured Query Language (SQL).
Hibernate provides Hibernate Query Language (HQL) which is similar to SQL syntax and supports polymorphic queries too. It also supports native SQL statements.

3. The mapping of Java objects with database tables has to be taken care of in JDBC. Hibernate provides transparent persistence and therefore there is no need to map database tables tuples to application objects during interaction with RDBMS.

4. With JDBC, caching needs to be manually maintained. Hibernate cache is set to application work space. Relational tuples are moved to this cache as a result of query. It improves performance during multiple writes for the same data.

5. In JDBC there is no check that always every user has updated data. Hibernate enables definition of version type field to application, due to which Hibernate updates version field of database table every time relational tuple is updated in form of Java class object to that table.
Hibernate - Why hibernate is advantageous over Entity Beans & JDBC.
Why hibernate is advantageous over Entity Beans & JDBC - An entity bean always works under the EJB container, which allows reusing of the object external to the container....
Hibernate - Difference between Entity Beans and Hibernate
Difference between Entity Beans and Hibernate - Entity beans are to be implemented by containers, classes, descriptors..
Hibernate - Difference between Hibernate and Spring
Difference between Hibernate and Spring - Hibernate is an ORM tool for data persistency. Spring is a framework for enterprise applications....
Post your comment
Discussion Board
Difference between JDBC and Hibernate
I have seen some answers related to this topic and I feel they are wrong. Actually we should not ask such question as we should not compare both. Hibernate works on ORM protocol and it shouldn't know how sql objects works. Whereas JDBC works on sql and data transfer protocols.

1) First thing is first. Hibernate doesn't work if JDBC protocol doesn't exist in communicating relational databases. Also hibernate is not just meant for JDBC. Hibernate is a ORM framework for various persistent storage software systems (This includes relational databases, xml objects, text objects etc). It all depends on how we want to link framework with persistent storage objects. For this we may depend on JDBC or any other protocol.
In short Hibernate framework is wrapper over JDBC API or some other api.

2) Hibernate avoids complexity in accessing the objects as underlying protocols or API will take care of data transmission and hibernate takes care of converting data to objects.

3) As everything works on collections and plain objects it is easy to developer in managing the proper code.
Sudhakar Chavali 08-23-2014