aspose file tools*
The moose likes Object Relational Mapping and the fly likes Should I use Hibernate? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Should I use Hibernate?" Watch "Should I use Hibernate?" New topic
Author

Should I use Hibernate?

Cory Max
Ranch Hand

Joined: Jul 20, 2005
Posts: 83
As a bit of a background, I am a Java programmer with 2 years of experience. We have written a couple of database driven web-apps using Struts. All of our database code was self written (connections, sql statements, etc).

We are starting a new Java project and have decided to take a look at hibernate. The thing is that our project is read-only from the database. We have nothing to write back to the database. The reason we would like to use hibernate is to get our feet wet with the technology and to get some of the benefits of using a robust db access framework (it manages connecting, connections, etc).

My question is: Is hibernate overkill for a read-only web application?


There are only 10 types of people in this world... Those who understand binary and those who don't.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Depends on the number of tables, and if later on you expect that you might want to update some of those tables. How complex are your queries could also play a role.

Personally after knowing how to use Hibernate, and having created my own ORM tool in VB. I would hate to have to write JDBC code ever again.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Cory Max
Ranch Hand

Joined: Jul 20, 2005
Posts: 83
We have about 20-25 tables and would be subject to minor change from time to time.

PS. Why would you write your own ORM tool in VB?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Originally posted by Cory Max:
We have about 20-25 tables and would be subject to minor change from time to time.

PS. Why would you write your own ORM tool in VB?


Because I got tired of writing String statements all over my code, when I can create a Class object and pass it to one method for all my tables. I just mapped my tables to the individual table class to the fields and it would automatically write the SQL for me, instead of many String sql statements typed by myself. This was VB 6.0

So knowing Hibernate, I know I could create the mappings with Annotations and a Generic DAO class is one week, and never write JDBC code again for an app with 20-25 tables.

Mark
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

You might find hibernate to be slower than writing jdbc directly. In general when dealing with 'object' stuff, speed of development is more important that speed of code. at least in the beginning.

I don't think hibernate manages connections that much. It will abstract away managemetn of jdbc connections, but the notion of connection will still exist in your application. There is some benefit to letting hibernate do that for you, but its not huge. However, it does grow as hibernate grows. Same with ORM.

I don't see any reason not to use Hibernate. It wont hurt anything and the time to deployment will probably be faster than if you wrote jdbc directly.
Cory Max
Ranch Hand

Joined: Jul 20, 2005
Posts: 83
Thanks for the replies folks. I spent 2 days reading on Hibernate and got a few examples to work. In the end I scrapped the idea for a few reasons:

- Timeline is very important on this project (and on every project I guess)
- New technologies (for us) present risks in terms of learning time and reduces our ability to solve problems quickly.
- We have a few developers that would need to get up to speed on this stuff fast and that didn't seem like a reality that could be achieved without someone to mentor us.

The coles notes of it are that the learning curve was too steep for us on this project compared with the benefits.

PS. In the end, wrote our solution using the DAO Pattern from the GAF and implemented connection pooling using C3P0 (which is the same open source connection pooling that hibernte uses).

Thanks everyone,

Cory
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Should I use Hibernate?
 
Similar Threads
Suggestion needed-J2ee 4 yrs exp
What audience is your book aimed at
Java desktop database app with JPA and Hibernate
Jasper Report or iReport or Both
deriving domain model - Hibernate style for web services