-->
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.  [ 2 posts ] 
Author Message
 Post subject: Row was updated or deleted by another transaction exception
PostPosted: Thu Mar 22, 2007 11:25 am 
Beginner
Beginner

Joined: Wed Mar 14, 2007 10:19 am
Posts: 24
I have two pojos, both of them have a collection bids.
What I want is to remove an element from this collection so I am using the following code:

Session session = HibernateUtil.getCurrentSession();
Thing thing = session.load(Thing.class, thingId);
Item item= session.load(Item.class, itemId);

thing.getBids().remove(bid);
item.getBids().remove(bid);

session.save(thing);
session.save(item);

session.close();


In my mapping files (Item.hbm.xml, Thing.hbm.xml) I have in the set
tag of the collections bids the property cascade="all-delete-orphan".

The above code works however if I try to delete 20-25 bids I get the following exception:

StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 1:33 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi juana,

Stale Object Exception is means that what ever reference of object you have is not the current state of DB .There is version difference. Stale object is expected Because of optimistic concurrency control by version. In your case if its works fine but some time it gets problem .Is this is your problem the either it is problem with multithreading (if u used) or while you are executing your code some body had updated that record. Means Dirty read problem .

_________________
Dharmendra Pandey


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