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.  [ 7 posts ] 
Author Message
 Post subject: Nullables support in newest NHib build (not-for-release ver)
PostPosted: Fri May 05, 2006 1:54 pm 
Newbie

Joined: Fri Apr 14, 2006 3:04 pm
Posts: 10
Hopefully someone can help me out here before I spend a lot of time doing something impossible.

Let's say I have a property in my object that's a datetime, and I want to make it nullable, ie:

private DateTime? m_EstimatedEndDate;

public virtual DateTime? EstimatedEndDate
{
get
{
return m_EstimatedEndDate;
}
set
{
m_EstimatedEndDate = value;
}
}

<property name="EstimatedEndDate" type="DateTime">
<column name="EstimatedEndDate" length="8"
sqlt-type="datetime"
not-null="false"/>
</property>


The problem is, when I set it up like this, and load the object, and say bind it to a grid, ie:

IList someList = session.CreateCriteria(typeof(MyClass)).SetMaxResults(100).List();
ListGrid.DataSource = someList;
ListGrid.DataBind();

...the EstimatedEndDate field disappears altogether. No errors...just gone. Poof. I've also tried changing the type in the mapping file to DateTime?...same results.

Anyone? The latest comments in JIRA seem to indicate this should be working. Am I doing something wrong? Thanks very much in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 2:10 pm 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
Is it not a grid characteristic?


Top
 Profile  
 
 Post subject: That's it...duh...thanks!
PostPosted: Fri May 05, 2006 2:44 pm 
Newbie

Joined: Fri Apr 14, 2006 3:04 pm
Posts: 10
The bug is with MS's GridView. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 07, 2006 4:18 am 
Regular
Regular

Joined: Fri Jul 29, 2005 9:46 am
Posts: 101
Hi... could you please explain how you found out that it is a bug in the GridView? (just curious)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
With 1.2-alpha1, I would typically map it like this:
Code:
<property name="EstimatedEndDate" column="EstimatedEndDate"/>

and NHibernate will figure out that it is nullable via reflection. I have been trying to find a way to explicitly tells NHibernate that the property is a DateTime?, but I am have not been able to find the proper value to use in the type="" attribute yet.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 2:08 pm 
Beginner
Beginner

Joined: Fri Jul 22, 2005 4:08 pm
Posts: 28
karlchu wrote:
I have been trying to find a way to explicitly tells NHibernate that the property is a DateTime?, but I am have not been able to find the proper value to use in the type="" attribute yet.


Does
Code:
type="Nullable<DateTime>"
not work? The question mark syntax is just syntactic sugar for producing a Nullable<> under the covers. of course I've never tried specifying generic types in NHibernate, so not even sure if that's supported.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 4:27 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can specify type="DateTime".


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