-->
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 design pattern problem
PostPosted: Thu Jul 08, 2010 6:02 am 
Newbie

Joined: Thu Jul 08, 2010 5:59 am
Posts: 1
I am quite new in Hibernate. I managed to learn myself a bit about Hibernate but the biggest problem I have is a designing problem. I use Hibernate with Spring, which is responsible for transactions and JSF, which I use in presentation layer. I use entities which represent database records and DAOs which implement database operations (one public DAO's method == a database transaction). I use also Spring's OpenSessionInViewFilter so in my application one Hibernate Session is connected with one HTTP request, so the objects I return from business layer to presentation layer are connected to the session during all one HTTP request. Consider please example like this:

Presentation layer code (the business one is obvious I suppose):

Code:
... 
User user1 = userDAO.get(1); //user login is "aaa"[code]     
User user2 = userDAO.get(2); 
user1.setLogin("bbb"); 
userDAO.makeSthWithThisObjectInTransaction(user2); 
user1.setLogin("ccc"); 
... 


After executing: the user1's login is bbb, because the changes made in persistent user1 object were committed during userDAO.makeSthWithThisObjectInTransaction(user2) method, after that user1 object is still attached to the session but no flush and commit operations are invoked.
I would prefer to invoke changes from presentation layer in more explicit way, because it works a bit sloppy now

Thanks for any help.

Best regards
Melmack


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.