-->
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.  [ 6 posts ] 
Author Message
 Post subject: An operation failed due to stale data-Urgent PLEASE
PostPosted: Tue Jun 28, 2005 8:46 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Please, please help me

Parent.hbm.xml
<class name="package.Parent" select-before-update="true" table="Parent" dynamic-update="true">
<id name="id" column="parentid" type="package.persistence.StringType"
unsaved-value="-1" >
<generator class="assigned" />
</id>
<set name="child" cascade="all" lazy="true" inverse="true">
<key column="Parent_id" />
<one-to-many class="Child" />
</set>

Child.hbm.xlm
<class name="package.Child" select-before-update="true" table="Child" dynamic-update="true">
<id name="id" column="ChildId" type="package.persistence.StringType" unsaved-value="-1" >
<generator class="assigned" />
</id>


Code


session = HibernateSessionFactory.currentSession();
tx = session.beginTransaction();
parent = (Parent) session.load(Parent.class, "999999");
parent.getChild().size();
session.flush();
tx.commit();
session.close();

// Modify the parent data
parent.setCorp("333333");

Child child = new Child();
edcsCase.setId("888888"); // Comment out then inserted with -1, uncommented gives Stale exception
child.setParent(parent);
if (parent.getChild() == null) {
parent.setChild(new HashSet());
}
parent.getChild().add(child);


session = HibernateSessionFactory.currentSession();
tx = session.beginTransaction();

session.update(parent); // update at root level


session.flush();
tx.commit();
session.close();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 8:48 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
I tried both in Same session and at different session
I am using version 2.1.7

Thanks for you time
rbarun


Top
 Profile  
 
 Post subject: Planning to go away from hibernate
PostPosted: Tue Jun 28, 2005 8:59 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
oh man
I tried my best to solve this issue, no help ....I am giving up. and going to remove hibernate from my project.

Thanks
rbaun


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 9:13 am 
Regular
Regular

Joined: Thu Apr 29, 2004 5:08 pm
Posts: 56
Location: Montreal, Quebec, Canada
Ahaha dude thank you for having making me laught this morning. You posted your 3 messages inside 15 min and are complaining you don't get any answers and want to drop Hibernate from your project.

Well do ahead and have fun writing your own persistence layer.

_________________
- Frank


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 9:17 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Hi fdelisle
I am posting the same message for the past one week. oh man...Finally one person atleast replied


Any help gurus

Thanks
rbarun


Top
 Profile  
 
 Post subject: I know this is a simple thing
PostPosted: Tue Jun 28, 2005 9:32 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Hi Guys
I know this is a simple thing and I am sure that everyone does these kind of update and sure hibernate has to support. But somewhere I am going wrong. Is there any GURUs to help.....

Thanks
rbarun


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