Difference between JDBC and Hibernate

Below are some differences between jdbc and hibernate –

Hibernate JDBC
Hibernate supports Inheritance, Associations, Collections Jdbc doesn’t support.
Hibernate supports relationships like One-To-Many,One-To-One, Many-To-Many-to-Many, Many-To-One Jdbc doesn’t supports relationships
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 In Jdbc all exceptions are checked exceptions, so we must write code in try, catch and throws
Hibernate has its own query language, i.e hibernate query language which is database independentSo if we change the database, then also our application will works well. By using DIALECT you can do this. Jdbc supports normal SQL queries, which is database dependent.
Hibernate supports caching mechanism , If you use caching then the number of database hits will be reduced, by using this caching technique an application performance will be increased automatically. Jdbc doesn’t support caching, but you can implement your own caching API.
Hibernate has capability to auto generate primary keys, you have to specify generator type (auto, sequence etc.) while we are storing the records into database But in Jdbc you can generate from java code or use through sql queries.
Hibernate supports annotations, apart from XML, takes less development time. In Jdbc you have to implement every thing, that takes more development time.
Good performance with small data Good performance with large data
Gopal Das
Follow me

Leave a Reply

Your email address will not be published. Required fields are marked *