Search This Blog

jdbc vs hibernate

Many of the negatives you listed are no longer applicable with Hibernate and JPA:
* No configuration / mapping files needed - You can use annotations
* No need to write HQL Queries - there are some named Queries needed - many IDE automatically generate them
* Not complex - Classes generated by IDE like Netbeans

Reasons for using Hibernate:
* No or very little coding needed with Generic DAOs and Spring Hibernate Templates
* Clean object oriented design - even implement object oriented relationships
* Second level cache improves database performance
* Why reinventing the wheel?
* Works well with Spring
* Easier to maintain

You may avoid Hibernate if your database is having:
* Bad old legacy database design
* Too many stored procedures
* Relations between objects are complex

There may be 200 others who may come back and say that using an ORM is bad. This is one of the most debated items in many boards. But my 2c - to have fast turnarounds ORM is a must.
or

I think that it depends on the kind of task that you are going to solve.
Hibernate uses JDBC for executing queries.

Hibernate is really good if you have real-world entities that are represented in db as tables. You can manipulate by these entities, add/delete etc....Also it makes sense to use it in the big project to improve reusability, scalability and speed of development.

But you can get into trouble when you need to create some big complicated, aggregated report or you have non-standard queries that requires a lot of inner selects, joins that requires data from different tables. Usually such types of queries have performance constraints.
For this case you need to user JDBC or IBatis to have flexibility of buidling sql query.