-->
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.  [ 6 posts ] 
Author Message
 Post subject: DateTime .Net 2 SQL Server
PostPosted: Tue Mar 21, 2006 4:03 pm 
Newbie

Joined: Tue Mar 21, 2006 3:46 pm
Posts: 2
Hi,

what is the best way to use DateTime type?

The DateTime field of my class mappings:
Code:
<property name="LastLogon" type="DateTime"/>


The Property in the class:
Code:
public DateTime LastLogon
{
   get { return m_dtLastLogon; }
   set { m_dtLastLogon = value; }
}




With the empty LastLogon I got an exception ;-(

Hibernate version: 1.0.2
.Net version: 2
Database: SQL Server

Thanks,
Dimi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 4:26 pm 
Newbie

Joined: Tue Mar 21, 2006 4:18 pm
Posts: 11
Database field "LastLogon" is defined with IS NULL constraint?
Probably candidate for using NullableDateTime ...

Code:
<property name="LastLogon" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate"/>


Code:
public DateTime? LastLogon
{
   get { return m_dtLastLogon; }
   set { m_dtLastLogon = value; }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 7:50 am 
Newbie

Joined: Tue Mar 21, 2006 3:46 pm
Posts: 2
I changed DateTime in DateTime? and it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 8:05 am 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
dimikaka wrote:
I changed DateTime in DateTime? and it works fine.


Yes, you can use DateTime? but just in your classes. Your hbm.xml continues the same.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 20, 2006 8:13 pm 
Newbie

Joined: Thu Apr 20, 2006 7:06 pm
Posts: 1
mdsrlz wrote:
dimikaka wrote:
I changed DateTime in DateTime? and it works fine.


Yes, you can use DateTime? but just in your classes. Your hbm.xml continues the same.



Please can you give me a short hint: What is the meaning of a type with a following "?". How does C# interprete "DateTime?" ?

Thanks
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 2:44 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Nullable


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