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.  [ 2 posts ] 
Author Message
 Post subject: How to specify date attribute in mapping files
PostPosted: Fri Apr 04, 2008 10:02 am 
Newbie

Joined: Sun Jan 27, 2008 4:26 pm
Posts: 18
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
1.2.1

Mapping documents:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace SiteAdminApp.Model
{
public class AdminValues
{
private int entryNo;
private string code;
private string detailsOfValue;
private int integerValue;
private float decimalValue;
private string stringValue;
private DateTime dateValue;
private string emailValue;

public AdminValues()
{
}
public virtual int EntryNo
{
get
{
return this.entryNo;
}
set
{
this.entryNo = value;
}
}
public virtual string Code
{
get
{
return this.code;
}
set
{
this.code = value;
}
}
public virtual string DetailsOfValue
{
get
{
return this.detailsOfValue;
}
set
{
this.detailsOfValue = value;
}
}
public virtual int IntegerValue
{
get
{
return this.integerValue;
}
set
{
this.integerValue = value;
}
}
public virtual float DecimalValue
{
get
{
return this.decimalValue;
}
set
{
this.decimalValue = value;
}
}
public virtual string StringValue
{
get
{
return this.stringValue;
}
set
{
this.stringValue = value;
}
}
public virtual DateTime DateValue
{
get
{
return this.dateValue;
}
set
{
this.dateValue = value;
}
}
public virtual string EmailValue
{
get
{
return this.emailValue;
}
set
{
this.emailValue = value;
}
}
}
}


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="SiteAdminApp" assembly="SiteAdminApp" auto-import="true">
<class name="SiteAdminApp.Model.AdminValues,SiteAdminApp" table="AdminValues" lazy="true" mutable="true">
<id name="EntryNo" column="EntryNo" type="int">
<generator class="native"></generator>
</id>
<property name="Code" column="Code" type="string"/>
<property name="DetailsOfValue" column="DetailsOfValue" type="string"/>
<property name="IntegerValue" column="IntegerValue" type="int"/>
<property name="DecimalValue" column="DecimalValue" type="Decimal"/>
<property name="StringValue" column="StringValue" type="string"/>
<property name="DateValue" column="DateValue" type="DateTime"/>
<property name="EmailValue" column="EmailValue" type="string"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

My code is:
using (NHibernate.ISession session = NHibernateSessionFactory.OpenSession())
using (NHibernate.ITransaction trns = session.BeginTransaction())
{
IList address = session.CreateCriteria(typeof(SiteAdminApp.Model.AdminValues)).List();
AdminValuesGridView.DataSource = address;
AdminValuesGridView.DataBind();
session.Transaction.Commit();

}

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Whenever i try to get a data from database or insert into data base i am getting error . My error is :SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Could you please tell me why ia m getting error.How to get rid of this.Is that mapping files are correct.If not provide me the correct code for those mapping files.It would be great if you tell me the answer.
Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 1:37 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I suppose you either have null values in that column or you try to write uninitalized date time values into the database. Try date time nullables (DateTime?) instead.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.