aspose file tools*
The moose likes Struts and the fly likes Struts 2 and Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 and Hibernate" Watch "Struts 2 and Hibernate" New topic
Author

Struts 2 and Hibernate

Nilesh Deshpande
Ranch Hand

Joined: Jan 11, 2006
Posts: 36
Does struts 2 has some added features for working on Hibernate?
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Actually, I don't think so. You can use hibernate with any framework, and if you use spring, it will make your life much easier. Struts 2 has its own integration with spring, but I've never heard with it having extra features for hibernate integration.


Visit my blog: http://jnassef.blogspot.com/
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
I've not used Hibernate with Spring, but I've certainly used Hibernate with Struts 2. If you google more, you would find that Hibernate does provide a filter and interceptor that could be used in Struts 2.



SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
chad michael davis
Author
Greenhorn

Joined: Mar 01, 2006
Posts: 27
There is no Hibernate specific integration support. But what would you be looking for ? I'm a bit suspicous of things like hibernate support and Ajax support; I'm not sure what they can provide of much depth.

In the book, we provide a chapter that shows how to integrate Hibernate/JPA with a Struts 2 application according to best practices. This includes a OSIV mechanism to handle the lazy loading in the view issue. And it shows how to use Struts 2 Spring integration to manage JPA/Hibernate; a very powerful combo!


Chad Davis<br />Co-author of Struts 2 in Action
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Struts is a MVC-based Presentation tier framework. It provides a skeleton with which developers can build the Controller and View components of an application.

Hibernate is an object-relational mapping framework for persisting data from the Model application. Code of the Controller and the View should not be coupled to any Hibernate syntax, any Hibernate-related tasks, any JDBC syntax or anything related to data persistence. These are distinctly different areas.
[ April 29, 2008: Message edited by: James Clark ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

Originally posted by chad michael davis:
This includes a OSIV mechanism to handle the lazy loading in the view issue.
What's the general consensus on OSIV? I've been "trained" through classical JDBC to open and close connections as quickly as possible, and so the concept of OSIV has always been a tad disquieting for me. Is this discomfort warranted in the least, or has OSIV proved to be scalable and performant in large-scale web apps using Hibernate (with Struts or otherwise)?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Originally posted by Bear Bibeault:
What's the general consensus on OSIV? I've been "trained" through classical JDBC to open and close connections as quickly as possible


Well, this is true, but sometimes you need to access DB stuff from your JSPs (or whatever your view is). You can always send everything to the DB, and get rid of lazy loading, but that would put a huge load on the network, especially if you have some many to many relationships. Another thing is that keeping one connection open till the processing of the page is far better than opening and closing several connections. Connection pooling also reduces a hell lot of load, so OSIV does not really have that big overhead you might thing it has. Just don't forget to close the session/connection with the response sending. I once wrote a small article on OSIV if you'd like to see it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 and Hibernate