-->
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.  [ 4 posts ] 
Author Message
 Post subject: Data between multiple hibernate sessions in single (CM) tx
PostPosted: Tue Jan 27, 2004 5:16 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Suppose I have the following running in a Stateless session bean method inside a container managed transaction:

Code:
// begin transaction (container)

Session session = factory.openSession();
Product x = session.load(Product.class, id);
String oldProductName = x.getName(); // foo
String newProductName = "bar"
x.setName(newProductName);
session.close();

Session session2 = factory.openSession();
Product x2 = session2.load(Product.class, id);
String nameInSecondSession = x2.getName();
session2.close()

// end transaction (container)


What is the value of nameInSecondSession? Is the data somehow 'shared' in the transaction?
My gut feel says that the x2.getName() should return "foo", but I would like to confirm. I currently don't have access to an application server in order to execute such a test and would therefore appreciate any feedback. Is there another way (without an app server) to check?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2004 8:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Should return foo since you don't flush your data.
If you flush, then should return bar

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2004 8:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
JOTM can help you to confirm

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 4:15 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
emmanuel wrote:
Should return foo since you don't flush your data.
If you flush, then should return bar


Thanks - I set up JBoss and deployed a simple Mapping and it works exactly as you mentioned.

Justin


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

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.