Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to use Hibernate?

 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd be interested in peoples opinions of when its appropriate to use Hibernate, or when its appropriate to use JDBC.

I would imagine if you are proficient in Hibernate, you would probably use it for all database applications irrespective of their complexity? Would you agree with this?

If you are fairly new to Hibernate, would you recommend using it for new applications irrespective of their complexity, or would you favour using plain JDBC or Spring/JDBC etc. as an alternative?

Cheers,

Dave.
 
Nick Heudecker
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd never go back to straight JDBC for any application. I tend to favor Hibernate for new development and iBATIS when I'm hired to retrofit existing JDBC applications.

A big part of why I favor Hibernate is because I already have the boilerplate code ready. It saves me a lot of the setup time normally associated with a new project.
 
Eusebio Floriano
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nick Heudecker:

A big part of why I favor Hibernate is because I already have the boilerplate code ready. It saves me a lot of the setup time normally associated with a new project.


Hi Nick,

In Hibernation Quickly do you demonstrate what this boilerplate might be ?

Regards,
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate is an awesome tool, but it's not the best solution for every situation.

Hibernate really shines when doing CRUD (create/retrieve/update/delete) operations on individual entities.

If I'm updating/deleting millions (or billions!) of rows, then JDBC will probably get the job done faster. (There's no need to retrieve 10 million entities just to call delete()).

If I'm aggregating data for a report, Hibernate would work well but I prefer JDBC. (Hibernate's not providing much advantage here.)

Hibernate is so flexible that I can mix and match it with JDBC in a single application. I can use Hibernate to connect to the database and perform some CRUD operations and then when it's time to do a mass delete I can call Session.connection() to get a reference to the underlying JDBC connection.

Regards,
Scott
 
Pj Murray
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is not one perfect Java persistence technology that is always the best choice. Otherwise there would not be so many competing specifications and technologies?

So sticking to one particular technology for all development projects means you'll get it wrong at least some of the time.

You may find these links useful

"Choosing a Java Persistence Strategy":

http://www.codefutures.com/weblog/andygrove/archives/2005/01/choosing_a_java.html

DAO versus ORM

http://www.codefutures.com/weblog/andygrove/archives/2005/02/data_access_obj.html
 
ansar basha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would also like to go for hibernate if my product is being host on different
dbs like mysql, oracle, M$SQL Server by different customers of mine as it
elementes recoding .

Thanks
Ansar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic