• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

integrating hibernate and struts: do we have to code separately and call struts?

 
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reading about using hibernate with struts and got confused from what was written about integration.Below is my understanding.Please confirm that this is correct.

For integrating struts with hibernate we just need to place hibernate jars in build path along with sruts jars.After this code for hibernate separately code for struts separately and call hibernate code from struts.Thats all we have to do. There is no such thing as intergrating hibernate with struts:we have to code struts and hibernate and then call hibernate.

thanks.
 
Ranch Hand
Posts: 331
Python Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yep!
both are different frameworks.
Your controller will call a method using the model, which in turn will use the hibernate context to deal with the database.
Ultimately a piece of 'code' will call another, whatever frameworks that you are using is just coincidental.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a Hibernate Plugin available for Struts 2 that provides Hibernate Validator integration, Hibernate Core Sessions and Transactions injection capabilities. Personally, we use a home-grown interceptor that obtains the session and injects it into interested actions.
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What i understand is it is separate Struts Code calling separate Hibernate Code.Then why is struts hibernate plugin used? what advantage would one get by using it instead of approach of separate Struts Code calling separate Hibernate Code.

thanks
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The plugin gives you a handy way to get a Hibernate session into your Action without you writing any code. You don't have to reinvent the wheel.
Whether or not the Action has any Hibernate code is up to you. If it is small enough, just a call to save() or createQuery, it may make sense to put the Hibernate code in the action (this option is depected in the Hibernate Integration tutorial). I tend to use the Action to assemble the required resources, then either invoke a business logic bean that does the work or directly call a data access object that contains the Hibernate code.
This Struts 1.3.x FAQ Entry is still relevant.
 
reply
    Bookmark Topic Watch Topic
  • New Topic