I'm new to NHibernate but have had great success so far in implementing a respectable data layer in my application using NHibernate. I have 8 persistable classes that I'm having zero problems with...However, I have one VERY small class that isn't behaving correclty.
After calling session.save(obj) on my object, I am returned the DB identity of the insert, but after the transaction is commited and the session closed, there is NOTHING in my table.
I'm using MS SQL server 2000 and NHibernate 1.20 CR1.
Am I missing something?
Mapping file:
Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace CleverDev.BusinessObjects
{
public class UserReportMap : CleverDevBusinessObject
{
private int _ID;
public virtual int ID
{
get { return _ID; }
set { _ID = value; }
}
private string _LastName;
public virtual string LastName
{
get { return _LastName; }
set { _LastName = value; }
}
private int _ReportID;
public virtual int ReportID
{
get { return _ReportID; }
set { _ReportID = value; }
}
public UserReportMap() { }
}
}
Mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="CleverDev.BusinessObjects.UserReportMap, CleverDev.BusinessObjects" table="UserReportMap">
<id name="ID" column="ID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="ReportID" column="ReportID" type="int" />
<property name="LastName" column="LastName" type="String" length="100"/>
</class>
</hibernate-mapping>
The log4net log file indicates that the save acutually happened but NOTHING in the table.
log file snippet:
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] <(null)> - Dehydrating entity: [CleverDev.BusinessObjects.UserReportMap#<null>]
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '125' to parameter: 0
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.Type.StringType [(null)] <(null)> - binding 'm' to parameter: 1
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.SQL [(null)] <(null)> - INSERT INTO UserReportMap (ReportID, LastName) VALUES (@p0, @p1); select SCOPE_IDENTITY(); @p0 = '125', @p1 = 'm'
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened IDataReader, open IDataReaders: 1
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - returning '1' as column:
2007-04-10 16:25:51,375 [8] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] <(null)> - Natively generated identity: 1