-->
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: Nullable Types and IQuery - Getting must have value error
PostPosted: Wed Jan 23, 2008 1:17 pm 
Newbie

Joined: Sun Oct 19, 2003 1:58 pm
Posts: 8
Location: Brentwood, TN
How do you set the value on a query for a replaceable parameter where the type is a nullable type (take your choice int?, DateTime?, etc.). I have beat my head against the wall trying to make this work. In conventional dynamic sql I would just set DBNull.Value for the parameter. But nothing I do has worked. I have tried the SetInt32, SetParameter, etc. Any suggestions would be good. Here is the query
Code:
IQuery query =
session.CreateSQLQuery("exec prc_EligibilityLookup-sp :memberId :productId :firstName :lastName :dateOfBirth :gender")
.SetString("memberId", eligibilitySearchCriteria.HealthPlanInsuranceMemberId)
.SetString("firstName", eligibilitySearchCriteria.FirstName)
.SetString("lastName", eligibilitySearchCriteria.LastName)
.SetEnum("gender", eligibilitySearchCriteria.Gender)
.SetInt32("productId", (int)eligibilitySearchCriteria.ProductId)
.SetDateTime("dateOfBirth", (DateTime)eligibilitySearchCriteria.DateOfBirth);

Note that the int and DateTime are nullable types.

thanks!

_________________
Don Eddleman


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 2:48 pm 
Newbie

Joined: Fri May 18, 2007 1:41 pm
Posts: 8
try
Code:
.SetParameter( "dateOfBirth", eligibilitySearchCriteria.DateOfBirth, NHibernateUtil.DateTime )


Top
 Profile  
 
 Post subject: RE:Nullable Types and IQuery - Getting must have value error
PostPosted: Wed Jan 23, 2008 3:28 pm 
Newbie

Joined: Sun Oct 19, 2003 1:58 pm
Posts: 8
Location: Brentwood, TN
thanks, I tried SetParameter with various other types including the nullables type but did not try it with their types. I'll give it a shot and let you know if that works.

_________________
Don Eddleman


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.