The Artima Developer Community
Sponsored Link

.NET Buzz Forum
NHibernate and .NET 2.0 Nullable Types

1 reply on 1 page. Most recent reply: Sep 30, 2005 6:53 PM by James Avery

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
James Avery

Posts: 1206
Nickname: james615
Registered: Sep, 2003

James Avery is a .NET pimp
NHibernate and .NET 2.0 Nullable Types Posted: Sep 30, 2005 6:53 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by James Avery.
Original Post: NHibernate and .NET 2.0 Nullable Types
Feed Title: .Avery Blog
Feed URL: /blog/Install/BlogNotConfiguredError.aspx
Feed Description: .NET and everything nice
Latest .NET Buzz Posts
Latest .NET Buzz Posts by James Avery
Latest Posts From .Avery Blog

Advertisement

On both my latest contract and an open source project I am working on we are using both .NET 2.0 and NHibernate. While NHiberate works just fine with 2.0, there is no native support for nullable types. There are some nullable types built into NHibernateContrib, but we would have to use their types instead of the normal .NET 2.0 types… this seemed like a bad solution. We tried a couple different options, but finally ended up with modifying the NHibernateContrib types to use the native .NET 2.0 types. I made a couple other small changes to the contrib code as well. Now you can do this in your mapping file:

<property name="TestBool" column= "boolCol" type="NHibernate.Nullables2.NullableBooleanType, NHibernate.Nullables2" />

The property TestBool is declared as “bool?” in the class, not a special nullable type.

This is really just a temporary solution until NHibernate is revised to include native support for these types, but if you are running into the same problems feel free to download it and give it a try. (let me know if you find any bugs or have any fixes)

Download Code.

-James

Read: NHibernate and .NET 2.0 Nullable Types


Naresh Bhatia

Posts: 1
Nickname: nbhatia
Registered: Oct, 2005

Re: NHibernate and .NET 2.0 Nullable Types Posted: Oct 25, 2005 6:32 AM
Reply to this message Reply
James,

Thanks for providing this library. I have found this to be the most elegant solution to handling nullables in .NET 2.0. The Nullables library that comes with NHibernateContrib does not serialize well over a Web Service. On the other hand, .NET 2.0 nullable are correctly supported by Web Services so your library is a perfect complement for NHibernate.

BTW, I have contributed an NHibernate cartridge to the AndroMDA project which demonstrates the use of Nullables2 in a sample application. AndroMDA along with my NHibernate cartridge allows developers to generate large portions of the data access layer using a UML model as the input. If you are anyone watching this post is interested, see the links below for more details. This stuff can save you hours or even days of work!

http://galaxy.andromda.org/forum/viewtopic.php?t=1120
http://galaxy.andromda.org/jira/browse/HIB-148

Naresh

Flat View: This topic has 1 reply on 1 page
Topic: Calculating a running average Previous Topic   Next Topic Topic: Il blog di mia moglie

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use