-->
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.  [ 3 posts ] 
Author Message
 Post subject: Foreign key can be null, how to model
PostPosted: Tue Jan 24, 2006 11:45 am 
Newbie

Joined: Tue Jan 24, 2006 11:15 am
Posts: 2
Location: Raleigh
Folks,

I'm sure this is a newbie question, but I have a foreign key as a property in my class. It is modeled as a .net guid and initialized to "guid.empty". When I add, I'd really like for the database to have a null inserted if the guid is empty.

Any thoughts on how to accomplish this?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 2:58 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Either use NullableGuid from the Nullables library (NHibernateContrib), or write your own custom type to translate between Guid.Empty and NULL.


Top
 Profile  
 
 Post subject: re: Foreign key can be null, how to model
PostPosted: Tue Jan 24, 2006 5:17 pm 
Newbie

Joined: Tue Jan 24, 2006 11:15 am
Posts: 2
Location: Raleigh
thanks for the answer. In the end I actually changed the initialization of the class to use the .net 2.0 nullable template so....
Nullable<Guid> m_myguid;

so, instead of Guid.Empty, the property could be initialized as null. Hibernate handled this just fine.

Thanks!


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