-->
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.  [ 5 posts ] 
Author Message
 Post subject: How do I insert a NULL into a numeric column?
PostPosted: Wed Feb 22, 2006 7:29 pm 
Newbie

Joined: Tue Feb 07, 2006 3:57 pm
Posts: 6
Hi,
I have a POCO with a "long" member mapped to a NUMERIC column of a table in the database. By default I get "0" inserted when I do an insert and not have a value specified for it. How can I get nhibernate to insert a NULL if it has no value instead of a 0?
Thanks,
Mel.



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Re: How do I insert a NULL into a numeric column?
PostPosted: Wed Feb 22, 2006 8:36 pm 
Newbie

Joined: Tue Feb 07, 2006 3:57 pm
Posts: 6
Mel wrote:
Hi,
I have a POCO with a "long" member mapped to a NUMERIC column of a table in the database. By default I get "0" inserted when I do an insert and not have a value specified for it. How can I get nhibernate to insert a NULL if it has no value instead of a 0?
Thanks,
Mel.


Basically, is there an equivalent of Java's Long object in C# that a null can be assigned to so that I can get Nhibernate to insert a NULL into the database or is there some other convention that someone can enlighten me about?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 11:50 am 
Newbie

Joined: Thu Oct 20, 2005 5:17 pm
Posts: 19
You can use the Nullables library in contrib to support Null values.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 12:42 pm 
Beginner
Beginner

Joined: Fri Nov 11, 2005 1:04 pm
Posts: 22
Jeff Bigler wrote:
You can use the Nullables library in contrib to support Null values.

That works or if you're using .Net 2.0 (VS2005), you can declare your object as Nullable<Long> and assign a null value to it. In your mapping file (or attributes) declare it as a Long.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 3:55 pm 
Newbie

Joined: Tue Feb 07, 2006 3:57 pm
Posts: 6
Hi Folks,
Thanks for the replies, I don't use .NET 2.0, so I downloaded the Nullables package and it works.
Thanks.


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