Hibernate version:1.0.2.0
Code between sessionFactory.openSession() and session.close():
Code:
ITransaction tx = null;
try
{
if (!session.IsConnected)
{
session.Reconnect();
}
Object result;
tx = session.BeginTransaction();
result = session.SaveOrUpdateCopy(obj);
session.Flush();
tx.Commit();
return result;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
if (tx != null)
tx.Rollback();
throw ex;
}
Full stack trace of any exception that occurs:
could not insert: [NHibernateTest.TestClass#0]
Name and version of the database you are using:MSSQL express obtained with VS2005
The generated SQL (show_sql=true):
?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernateTest.TestClass, NHibernateTest" table="TestClasses">
<!-- map the id field -->
<id name="Id" column="Route_ID" type="int">
<generator class="assigned" />
</id>
<property name="Name" column="Name" type="String"/>
<property name="Layout" column="Layout" type="String"/>
<property name="Frequency" column="Frequency" type="int"/>
</class>
</hibernate-mapping>
But it does not work correctly. Exception "Can't insert" is appeared.
How can I resolve this problem?