-->
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: Can we update one table in the tree
PostPosted: Tue Jun 21, 2005 9:32 pm 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Hi Guys,
I am using Hibernate 2.1.x. trying to update middle table in the tree. it give stale exception

Here is the scnario

While retriving I have
Parent
ChildA
ChildA

now I need to add

another ChildA as a third row, but it fails

Like
Parent ( Update )
ChildA (Update )
ChildA ( update )
ChildA ( insert )



2. How do I add only childA into table,


Thanks for your Time

Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 10:24 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
Ramesh,

It is possible.

Make sure that you set the cascade="all" or "save-update" (check documentation for the correctnes..

Refer to the hibernate reference pdf that comes along with the hibernate zip, It contains a lot of examples.

Hope it helps.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 22, 2005 8:19 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Hi Mahikty
I tried as per the document, but it did't work for me . I am using 2.1.7


Here is the Code
edcsFldr = (Fldr) session.load(Fldr.class, "999999");
if ( edcsFldr != null ) {
System.out.println("Folder Num = "+ edcsFldr.toString());
System.out.println("Folder Num = "+ edcsFldr.getCid());
System.out.println("Folder Num = "+ edcsFldr.getErlstEffFlgDt());
}
edcsFldr.setCossn("333333"); // modifie the data
edcsFldr.setCid("00");


// add new Case data
Case edcsCase = new Case();
edcsCase.setId("888888");

edcsCase.setFldr(edcsFldr);
edcsFldr.setCases(new HashSet());
edcsFldr.getCases().add(edcsCase);

System.out.println("Case count : " + edcsFldr.getCases().size()); // I got one
session.save(edcsCase);
session.flush();

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


Here is xml
<set name="cases" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="FLDR_NUM" />
<one-to-many class="Case" />
</set>

I tried both

session.save(edcsCase); // Child update -- did not inserted a child nor updated the parent.
session.save(edcsFldr); // Parent Update --got stale exception


Any help is greatly appriciated

Thanks
rbarun


Top
 Profile  
 
 Post subject: Is it to do anything with version 2.1.7 and 3.0
PostPosted: Wed Jun 22, 2005 8:34 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Is it to do anything with version 2.1.7 and 3.0


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.