-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate with Struts
PostPosted: Fri May 22, 2009 10:40 pm 
Newbie

Joined: Mon Apr 13, 2009 11:09 pm
Posts: 3
I'm working with a company that had Hibernate partially introduced by a contractor (now gone) to replace their current persistence framework, which had been generated DAOs using a product called Firestorm. They feel Hibernate isn't fitting into their system well. I've tried to understand some of their problems:

One problem is they retrieve data in Session Beans, which is where the Hibernate Session lives. Then they pass the model classes up to the Struts layer, where they are copied into Struts Action Forms. The user may edit the values, then submit it back through the Struts Layer and down into Session Bean. However, the Hibernate Session that retrieved the data is now gone, and a new session must be started and specifically told to insert or update the record. It seems to me this is not using Hibernate the way it's meant to be used. I've started researching something called "Open Session in View". Am I on the right track?

Another big problem is when there are relations to other classes. Let's say a new "Branch" belongs to a "Division". Part of creating or editing a Branch is setting the Division from the list of existing Divisions. Saving the Branch doesn't affect the related Division in anyway, but there is a foreign key relationship in the database. With Firestorm classes, they just had to set the Division ID into the Branch DTO and persist it. With Hibernate, the contractor defined Branch to have a reference to a Division object. Because the Hibernate Session is disconnected from retrieve to update, he had to pass down the Division ID in a separate object, then use it to look up a Division, then set this Division to the Branch, and finally do the update/insert. If not, Hibernate seemed to get confused and tried insert a new Division division record. With some of the complicated entities, there are half a dozen of these kind of relationships, so coding the persistence becomes really a bit of a pain ... and really ugly as well. I'm not sure if they should just define Branch to have a DivisionID rather than a Division object the way Firestorm does it, or maybe the Open Session in View is going to solve this problem too.

Sorry for all the words. These problems seem like they'd be common to any app that uses a Struts web layer and an EJB persistence layer. I assume there are best practices that deal with the situation nicely. Can anyone point me to them?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.