-->
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.  [ 3 posts ] 
Author Message
 Post subject: What will happened if two thread load the same object ?!!
PostPosted: Wed Sep 01, 2004 8:44 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

There is a problem puzzled me all the time. We load an object from database in this way :
Code:
Trade trade=(Trade)session.load(Trade.class,trade_id);
trade.setName(....);
trade.setContent(...);
session.update(trade);


But I think there is a problem! If two thread load the same object and change it in the same time, what will happened?
Whether the data in database will be not identical? I mean that they will be not consistent. Or the database will be lock a long time when it in a long transaction.
I don't use Lock Modal because it is not need to do this everytime I load an object. Some one give me some idea? Help!

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 9:55 pm 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
If you don't use versionning, both threads change the object, and the last wins.

If you use versionning, the first thread wins, and the second get an exception.

mota


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 2:38 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
This higly depends on the isolation level you are using. You might get an exception, have the second transactoin winning or the DB forces serialization of the transctions.

Get the Hibernate in Action book and read chapter 5.1.4 to learn the details.

HTH
Ernst


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.