-->
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: Strange behaviour of version incrementation. Please help!
PostPosted: Thu Jan 03, 2008 4:48 am 
Newbie

Joined: Thu Jan 03, 2008 4:16 am
Posts: 4
NHibernate 1.2.1.4000

I´m new here, so hello all!

I encountered some strange behaviour with the incrementation of the version column. A very simple Example:

There is an Employee with a related Person. Both mappings contain a <version> tag. The Employee´s Person assoziation is declared as lazy="true".

If I load the Employee, modify a Employee specific Property (e.g. personnelNumber) and update this Employee the version of the Employee is incremented by 1. That seems correct.

But if I either switch the Employee´s Person assoziation to lazy="false" or fetch the Person by calling employee.Person and do exactly the same Update as described above the Person´s version number is incremented too, although I did not change the Person at all.
That seems odd! This behaviour applies to the complete object graph, if the person refernces a list of contacts for example this versions are incremented too.

So please give me some advice of how to handle that! For me the only usefull behaviour would be that solely the employee´s version gets incremented, because it was solely the employee I changed. No matter whether the relations are lazy="false" or are fetched by a call.

Anyway, excuse my english!

Regards,
Christian


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 6:28 am 
Newbie

Joined: Thu Jan 03, 2008 4:16 am
Posts: 4
Ok, I tried it with two very simple classes A and B and can not reproduce this behavior ... I`m sorry I will try to find out whats wrong with my complexer classes !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 8:03 am 
Newbie

Joined: Thu Jan 03, 2008 4:16 am
Posts: 4
can´t delete ;)


Last edited by gourmete on Thu Jan 03, 2008 8:06 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 8:05 am 
Newbie

Joined: Thu Jan 03, 2008 4:16 am
Posts: 4
Ok, I found it...

The problem was that I did use an enum in my entities. In the mapping I did not specify that enum Type but Int32. It works without Exceptions, Hibernate casts the enum to int and vice versa. But (I don´t know why) it does an Update on the object even if nothing was changed.

Now with the correct enum Type in the mapping everything works as expeted! Tricky!!!


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.