-->
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: version was update when select
PostPosted: Sun Jun 19, 2005 6:07 am 
Newbie

Joined: Sun Jun 19, 2005 5:52 am
Posts: 3
I add an int Version Column / Property to a class. The version number of objects was incremented when object updated and also where selected by a query. I think this is in contradiction with Optimistic-Locking method. So when an object was read, an other previously readed operation must can update the object.
How can i resolve this?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 19, 2005 4:20 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This often happens when you have a field that is NULL and it is mapped to a property that can't be null (such as int, DateTime, etc.). When such a field is loaded the property is initalized to its default value (which is not null) and this default value is then saved, that's why the version is incremented.

The solution is usually to use Nullables from the NHibernateContrib package for such properties.

Of course the problem may be somewhere else entirely, so please provide more details (your mappings, your classes, your code) if I guessed wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 8:21 am 
hi,

I' ve a similar problem.

I've got a class Customer with a lazy collection of Addresses. The Address class has a many-to-one relation with Country class.

If I load a Customer object, without initialize the Addresses collection and then I load all Country objects, the Customer version changes. When I load the countries list first It doesn't hapen. Any suggestion?


Top
  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 2:11 am 
Newbie

Joined: Sun Jun 19, 2005 5:52 am
Posts: 3
I found that xml property types must completely match to class property types. for example Int32 matches int.


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.