-->
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: Simple problem - i've probably misunderstood semantics?
PostPosted: Tue Jul 18, 2006 11:47 am 
Newbie

Joined: Fri Feb 10, 2006 6:02 am
Posts: 15
If someone can point me in the right direction I would be very appreciative.

@Version not working as I expected with cascade saving.

I have 2 classes: PARENT_CLASS and CHILD_CLASS.

PARENT_CLASS contains a set of CHILD_CLASS.

Both class PARENT_CLASS and CHILD_CLASS have a field annotated @Version.

If I call merge() on either PARENT_CLASS or CHILD_CLASS their respective version number is incremented.

However, if I add a new instance of CHILD_CLASS as a child to an instance of PARENT_CLASS and then call merge() on parent instance, the version number for the PARENT_CLASS is incremented, but the CHILD_CLASS version is inserted into the database as 0 when the merge is cascaded to the child.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 4:26 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Quote:
However, if I add a new instance of CHILD_CLASS as a child to an instance of PARENT_CLASS and then call merge() on parent instance, the version number for the PARENT_CLASS is incremented, but the CHILD_CLASS version is inserted into the database as 0 when the merge is cascaded to the child.


What should it be by your opinion / or what's the problem?
Isn't 0 correct since child is a new instance?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 5:31 am 
Newbie

Joined: Fri Feb 10, 2006 6:02 am
Posts: 15
I think the problem is my fault!

0 is the version assigned to a new instance - and is working fine - i had just misunderstood the numbering.

I am still a little confused though. I have the following scenario.

1. I create a new child (with a reference to the parent). save it to the database and it is given version == 0. I have not saved the parent yet.
2. I save the parent with the child in it's set. Now the child in the database has a version number == 3.

Why does the version jump from 0 to 3?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 5:44 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Repeat the same scenario with sql logging turned on.
Look for updates on this child instance.


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.