-->
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: Why [not-null="false"] doesn't work on Int columns
PostPosted: Wed Aug 10, 2005 1:44 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Hi guys,

Hibernate seem to systematically "detect" my nullable int columns as dirty and updates them to "0".... [not-null="false"] in mapping doesn't seem to change this behaviour.
For ex:
I have a SQL server column [Rating] [int] NULL.
I have a class with:
Quote:
Public Property rating() As Integer
Get
Return _rating
End Get
Set(ByVal Value As Integer)
_rating = Value
End Set
End Property

My mapping file goes like: <property name="rating" column= "rating" not-null="false" />
And yet, for all cases WHERE [Rating] is NULL - I get: NHibernate.Persister.AbstractEntityPersister - d001.Blahblah.Class1.rating is dirty...
Am I missing something here?
Many thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 3:28 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Currently NHibernate requires using a nullable type for nullable integers (from Nullables library of NHibernateContrib package). Or you can write your own UserType that will save 0 as NULL. Search the Wiki for Nullables, there was a usage example there somewhere.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 9:37 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Here is the example using Nullables:
http://wiki.nhibernate.org/display/NHC/Nullables

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 4:15 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Thanks guys!


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.