Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 and Hibernate

 
Nilesh Deshpande
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does struts 2 has some added features for working on Hibernate?
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
chad michael davis
Author
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)?
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic