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