-->
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: NullableDateTime property refuses to set
PostPosted: Sun Aug 07, 2005 12:04 pm 
Newbie

Joined: Sun Aug 07, 2005 8:23 am
Posts: 3
Hi there,

I'm using a NullableDateTime property in an object, but oddly enough .NET refuses to set the property during session.createCriteria.List when the database field contains "null" (the exact opposite of what I would expect :) ).

Here's the exception:

Code:
   _innerException   {"The type System.DateTime can not be assigned to a property of type Nullables.NullableDateTime setter of LearningAlive.Content.ScheduleEnd" }   System.Exception


I have referenced the .dll files Nullables.dll and Nullables.Nhibernate.dll in my VS.NET environment. The relevant parts of the class file looks like this:

Code:
using Nullables;
...<snip>...
      private NullableDateTime scheduleStart;
      private NullableDateTime scheduleEnd;
...<snip>...
      public NullableDateTime ScheduleStart
      {
         get { return scheduleStart;}
         set { scheduleStart = value;}
      }
      
      public NullableDateTime ScheduleEnd
      {
         get { return scheduleEnd;}
         set { scheduleEnd = value;}
      }


The relevant part of the mapping file is:

Code:
      <property name="ScheduleStart" column="schedule_start" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
      <property name="ScheduleEnd" column="schedule_end" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />


I've tried using NhibernateContrib .9 and .8.4 and get the same result. I am probably doing something quite dumb so feel free to have a chuckle when you tell me if this is the case.

One other minor question which could be related - if I want to use the Nullables types from Contrib, do I just use the .DLLs from the Contrib package and ignore the same ones from the regular NHibernate package? This is what I'm doing, there's no indication of how to install the contrib files anywhere and the regular NHibernate DLL filenames are the same so I figured that was the way to go.

Do I need to put "using Nullables;" somewhere other than in the class file itself, like maybe in the data access object that is doing the retrieval?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 07, 2005 12:30 pm 
Newbie

Joined: Sun Aug 07, 2005 8:23 am
Posts: 3
OK, actually there was a problem due to the fact that I had a joined-subclass which still defined the ScheduleStart and ScheduleEnd properties as DateTime types, and were overriding the NullableDateTimes set up in the superclass. I took them out, and now I have progressed to another error after purging the class files and mapping files of DateTime references:

Code:
{"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM." }


Top
 Profile  
 
 Post subject: Initialize properties values and mapping
PostPosted: Mon Aug 15, 2005 3:45 pm 
Newbie

Joined: Mon Aug 15, 2005 3:33 pm
Posts: 1
futurechimp wrote:
OK, actually there was a problem due to the fact that I had a joined-subclass which still defined the ScheduleStart and ScheduleEnd properties as DateTime types, and were overriding the NullableDateTimes set up in the superclass. I took them out, and now I have progressed to another error after purging the class files and mapping files of DateTime references:

Code:
{"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM." }


Try to use not-null="false" attribute in property defenition.
Datetime type in .Net is not equal SQL (or other DB) Datetime.
SQL Datetime start value from 1/1/1753 12:00:00
.Net 1/1/1700 12:00:00 (if I correct remember)


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.