wood burning stoves 2.0*
The moose likes Struts and the fly likes Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Hibernate" Watch "Hibernate" New topic
Author

Hibernate

Abhijeet Thacker
Greenhorn

Joined: Jan 15, 2005
Posts: 16
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??


Always code as if person who is going to maintain your code is a maniac serial killer and knows where you live
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
HibernatePlugin for struts

http://sourceforge.net/projects/struts


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
AppFuse (http://appfuse.dev.java.net) and Equinox (http://equinox.dev.java.net) have examples of using Hibernate with Struts (and Spring!).


Matt<br /> <br />Author: <a href="http://springlive.com" target="_blank" rel="nofollow">Spring Live</a> and <a href="http://www.apress.com/book/bookDisplay.html?bID=256" target="_blank" rel="nofollow">Pro JSP</a><br />Weblogs: <a href="http://raibledesigns.com" target="_blank" rel="nofollow">Raible Designs</a> <a href="http://jroller.com/page/raible" target="_blank" rel="nofollow">Spring Live Blog</a>
George Franciscus
author
Ranch Hand

Joined: Jan 25, 2005
Posts: 32
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.


George Franciscus<br />george.franciscus@nexcel.ca<br /><a href="http://www.nexcel.ca" target="_blank" rel="nofollow">http://www.nexcel.ca</a><br /><a href="http://www.manning.com/franciscus" target="_blank" rel="nofollow">http://www.manning.com/franciscus</a>
 
jQuery in Action, 2nd edition
 
subject: Hibernate