• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I use Hibernate?

 
Cory Max
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Cory Max
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic