-->
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.  [ 2 posts ] 
Author Message
 Post subject: Number column is nullable? How to map?
PostPosted: Mon Jun 20, 2005 10:04 am 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
hi,

I have a number column with possible value null, 0, 1.

How shall I define the object and the mapping so that when read data from the DB, I can know it's null or 0?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 5:16 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
well i'm not sure if you are using the "number" as a boolean, but if you are you could define it as a Nullables.NullableBoolean.

Otherwise there are NullableInt16, NullableInt32 and NullableInt64.

Code:
using Nullables;

public class MyClass {
  private NullableBoolean myNumber;

  public NullableBoolean MyNumber {
    get { return this.myNumber; }
    set { this.myNumber = value; }
  }
}


Code:
<class name="MyClass>
  <id></id>

  <property name="MyNumber" type="Nullables.NHibernate.NullableBooleanType, Nullables.NHibernate" />
</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.