• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integrating Struts2 with Hibernate

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to develop a web application using Struts2 as my UI and Hibernate as my Model.

I made a Hibernate Util class for opening and closing session.

Please tell me will it be a right approach if i use Interceptors for getting reference to session in Util class. If not then what is the best place ?

Anybody please help.
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I have the Struts 2 in Action book and in that they have used Spring as a middle man to make Struts work with Hibernate. And the flow is really simple. If you like this idea, then you can look at these pages

http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html

http://www.codeweblog.com/struts2-spring-hibernate-s-easy-to-integrate/

http://www.vitarara.org/cms/struts_2_cookbook/integration_testing
 
kurt hanni
Ranch Hand
Posts: 140
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes you could do it with interceptors.

or you can add spring in your integration, and use spring-AOP for opening and closing hibernate sessions/transactions. Spring has great support for hibernate and would relieve you of writing lots of boilerplate code. You'll find you're coding and structure much simpler.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Hanni and Ankit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic