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.  [ 1 post ] 
Author Message
 Post subject: HELP...DB Identity returned but record doesn't exist in tabl
PostPosted: Tue Apr 10, 2007 4:44 pm 
Newbie

Joined: Mon Apr 02, 2007 4:29 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.