Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate

 
Abhijeet Thacker
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please can anybody let me know that what is hibernate and how to use it with struts ?? can some one please suggest me any good book or online examples or tutorials for the same??
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HibernatePlugin for struts

http://sourceforge.net/projects/struts
 
Matt Raible
author
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AppFuse (http://appfuse.dev.java.net) and Equinox (http://equinox.dev.java.net) have examples of using Hibernate with Struts (and Spring!).
 
George Franciscus
author
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate is a persistence framework with a strong orientation to addressing the object-relational impedance problem. Data is stored in a relational structure, but your Java design wants to interact with them as objects. Hibernate is a tool to allow you to interact with you relational data as objects. Hibernate is good for rich domain architectures. Hibernate isn't the only persistence framework that can do that, but its very good at it.

You can either use Hibernate with Struts -or- you can use Hibernate and Struts. There's a difference.

Matt pointed out the Struts plugin that can be used to use Hibernate with Struts. Although the plugin works very well, you must resign to the fact that your Struts Action is going to know about Hibernate. If you need to switch from Hibernate to something else (say iBATIS), then you need to touch a lot of code. A better approach is to use Struts and Hibernate.

Using Struts and Hibernate means that you use them both, but neither knows about each other. The best approach to that is to create a layered application using DAOs. The DAO hides the fact that you are using Hibernate. This allows you to have an orthogonal application. That is to say, the two can co-exist, and can change without impacting each other.

You asked if there are any books on the subject. Funny you should ask that .... In Struts Recipes we present two recipes on both strategies. We have a recipe that shows how to use the Struts Hibernate plug-in. We have another recipe that shows how to create a layer Struts application. We show it both ways!

Another good approach is wiring up Struts to Spring, then wire Spring to Hibernate. Matt's book will show you how to do that.

There you have it. You asked one question and I gave you three answers. Sorry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic