-->
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.  [ 7 posts ] 
Author Message
 Post subject: NHibernate won't delete, but won't thow an exception either
PostPosted: Tue Jul 22, 2008 10:54 am 
Newbie

Joined: Tue Jul 22, 2008 10:24 am
Posts: 4
Hi,

I've been using NHibernate for a short while now and am stuck on a problem that is puzzling me.

The problem
Some entities I have created refuse to be deleted from the database, while others have no problem. No exception is ever thrown, nor any error's raised. HNibernate seems to run past the delete and execute it, it's just that nothing actually happens. SQL Server does Not get any Delete command send to it.

While on most places it goes ok the most prime example (which I will post here) of the few times it doesn't "do anything" is the Internal Message system for the software I'm building. This is basically a message, connected to a product with a from and to user inside the system. No actual connection is kept to the product as one of the messages can be that the product was deleted from the system (I keep the ID and Name for display reasons. The ID actually being not a forreignkey anymore. I'm just using for debug reasons to see what is going on, no dependency if the product actually exists. It's just an Int and nothing more for the software))

Mapping file

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Domain" assembly="Domain" default-lazy="false" default-access="field.camelcase">
    <class name="Message" table="Messages" mutable="true">
        <cache usage="nonstrict-read-write" region="Entities"/>
       
        <id name="Id" column="Id" access="nosetter.camelcase" unsaved-value="0">
            <generator class="identity" />
        </id>

        <timestamp name="InsertTimestamp" column="InsertTimestamp" />

        <many-to-one name="ToUser" column="ToUserID" class="Domain.User" not-null="true" cascade="none" />
        <many-to-one name="FromUser" column="FromUserID" class="Domain.User" not-null="true" cascade="none"/>

        <property name="wrProductId" >
            <column name="WrProductID"/>
        </property>
       
        <property name="wrProductName" >
            <column name="WrProductName"/>
        </property>

        <property name="Status" >
            <column name="Status"/>
        </property>       
       
        <property name="Message" >
            <column name="Message"/>
        </property>

    </class>
</hibernate-mapping>


(I'm just storing the product ID and Name directly here, not actually connecting to them, I used to have many-to-one relations that did not effect the behavior of the delete)

The Log

Code:
NHibernate.Impl.SessionImpl: 15:29:19.701 [4] DEBUG NHibernate.Impl.SessionImpl - opened session
NHibernate.Impl.SessionImpl: 15:29:19.701 [4] DEBUG NHibernate.Impl.SessionImpl - delete: FROM Domain.Message as Message WHERE Message.Id = ?
NHibernate.Impl.SessionImpl: 15:29:19.701 [4] DEBUG NHibernate.Impl.SessionImpl - parameters: 8
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - find: FROM Domain.Message as Message WHERE Message.Id = ?
NHibernate.Engine.QueryParameters: 15:29:19.717 [4] DEBUG NHibernate.Engine.QueryParameters - parameters: [8]
NHibernate.Hql.Classic.QueryTranslator: 15:29:19.717 [4] DEBUG NHibernate.Hql.Classic.QueryTranslator - compiling query
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - flushing session
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - Processing unreferenced collections
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
NHibernate.Impl.SessionImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.SessionImpl - dont need to execute flush
NHibernate.Hql.Classic.QueryTranslator: 15:29:19.717 [4] DEBUG NHibernate.Hql.Classic.QueryTranslator - HQL: FROM Domain.Message as Message WHERE Message.Id = ?
NHibernate.Hql.Classic.QueryTranslator: 15:29:19.717 [4] DEBUG NHibernate.Hql.Classic.QueryTranslator - SQL: select messag0_.Id as Id26_, messag0_.InsertTimestamp as InsertTi2_26_, messag0_.ToUserID as ToUserID26_, messag0_.FromUserID as FromUserID26_, messag0_.WrProductID as WrProduc5_26_, messag0_.WrProductName as WrProduc6_26_, messag0_.Status as Status26_, messag0_.Message as Message26_ from _devel_imported.dbo.Messages messag0_ where (messag0_.Id=? )
NHibernate.Impl.BatcherImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands: 1
NHibernate.Impl.BatcherImpl: 15:29:19.717 [4] DEBUG NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: select messag0_.Id as Id26_, messag0_.InsertTimestamp as InsertTi2_26_, messag0_.ToUserID as ToUserID26_, messag0_.FromUserID as FromUserID26_, messag0_.WrProductID as WrProduc5_26_, messag0_.WrProductName as WrProduc6_26_, messag0_.Status as Status26_, messag0_.Message as Message26_ from _devel_imported.dbo.Messages messag0_ where (messag0_.Id=? )
NHibernate.Type.Int32Type: 15:29:19.717 [4] DEBUG NHibernate.Type.Int32Type - binding '8' to parameter: 0
NHibernate.Loader.Loader: 15:29:19.733 [4] INFO  NHibernate.Loader.Loader - select messag0_.Id as Id26_, messag0_.InsertTimestamp as InsertTi2_26_, messag0_.ToUserID as ToUserID26_, messag0_.FromUserID as FromUserID26_, messag0_.WrProductID as WrProduc5_26_, messag0_.WrProductName as WrProduc6_26_, messag0_.Status as Status26_, messag0_.Message as Message26_ from _devel_imported.dbo.Messages messag0_ where (messag0_.Id=@p0 )
NHibernate.SQL: 15:29:19.733 [4] DEBUG NHibernate.SQL - select messag0_.Id as Id26_, messag0_.InsertTimestamp as InsertTi2_26_, messag0_.ToUserID as ToUserID26_, messag0_.FromUserID as FromUserID26_, messag0_.WrProductID as WrProduc5_26_, messag0_.WrProductName as WrProduc6_26_, messag0_.Status as Status26_, messag0_.Message as Message26_ from _devel_imported.dbo.Messages messag0_ where (messag0_.Id=@p0 ); @p0 = '8'
NHibernate.Connection.DriverConnectionProvider: 15:29:19.733 [4] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
NHibernate.Impl.BatcherImpl: 15:29:19.733 [4] DEBUG NHibernate.Impl.BatcherImpl - Opened IDataReader, open IDataReaders: 1
NHibernate.Loader.Loader: 15:29:19.733 [4] DEBUG NHibernate.Loader.Loader - processing result set
NHibernate.Loader.Loader: 15:29:19.733 [4] DEBUG NHibernate.Loader.Loader - result set row: 0
NHibernate.Type.Int32Type: 15:29:19.733 [4] DEBUG NHibernate.Type.Int32Type - returning '8' as column: Id26_
NHibernate.Loader.Loader: 15:29:19.733 [4] DEBUG NHibernate.Loader.Loader - result row: 8
NHibernate.Loader.Loader: 15:29:19.733 [4] DEBUG NHibernate.Loader.Loader - Initializing object from DataReader: [Domain.Message#8]
NHibernate.Loader.Loader: 15:29:19.733 [4] DEBUG NHibernate.Loader.Loader - Hydrating entity: Domain.Message#8
NHibernate.Type.TimestampType: 15:29:19.733 [4] DEBUG NHibernate.Type.TimestampType - returning '11:11' as column: InsertTi2_26_
NHibernate.Type.GuidType: 15:29:19.748 [4] DEBUG NHibernate.Type.GuidType - returning '1d5bddf7-ef28-47dd-b61d-91d5856a2431' as column: ToUserID26_
NHibernate.Type.GuidType: 15:29:19.748 [4] DEBUG NHibernate.Type.GuidType - returning '1d5bddf7-ef28-47dd-b61d-91d5856a2431' as column: FromUserID26_
NHibernate.Type.Int32Type: 15:29:19.748 [4] DEBUG NHibernate.Type.Int32Type - returning '2' as column: WrProduc5_26_
NHibernate.Type.StringType: 15:29:19.748 [4] DEBUG NHibernate.Type.StringType - returning 'testje' as column: WrProduc6_26_
NHibernate.Type.Int32Type: 15:29:19.748 [4] DEBUG NHibernate.Type.Int32Type - returning '0' as column: Status26_
NHibernate.Type.StringType: 15:29:19.748 [4] DEBUG NHibernate.Type.StringType - returning 'Tweede testje voor display. Maar dit keer met een stuk meer tekst enzo. Tralalla enzo' as column: Message26_
NHibernate.Impl.SessionImpl: 15:29:19.748 [4] DEBUG NHibernate.Impl.SessionImpl - Version: 26-6-2008 11:11:52
NHibernate.Loader.Loader: 15:29:19.748 [4] DEBUG NHibernate.Loader.Loader - done processing result set (1 rows)
NHibernate.Driver.NHybridDataReader: 15:29:19.748 [4] DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
NHibernate.Impl.BatcherImpl: 15:29:19.748 [4] DEBUG NHibernate.Impl.BatcherImpl - Closed IDataReader, open IDataReaders :0
NHibernate.Impl.BatcherImpl: 15:29:19.748 [4] DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands: 0
NHibernate.Impl.ConnectionManager: 15:29:19.748 [4] DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing database connection
NHibernate.Connection.ConnectionProvider: 15:29:19.748 [4] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
NHibernate.Loader.Loader: 15:29:19.748 [4] DEBUG NHibernate.Loader.Loader - total objects hydrated: 1
NHibernate.Impl.SessionImpl: 15:29:19.748 [4] DEBUG NHibernate.Impl.SessionImpl - resolving associations for: [Domain.Message#8]
NHibernate.Impl.SessionImpl: 15:29:19.748 [4] DEBUG NHibernate.Impl.SessionImpl - loading [User#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.748 [4] DEBUG NHibernate.Impl.SessionImpl - attempting to resolve [User#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Cache.NonstrictReadWriteCache: 15:29:19.748 [4] DEBUG NHibernate.Cache.NonstrictReadWriteCache - Cache lookup: Domain.User, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#1d5bddf7-ef28-47dd-b61d-91d5856a2431
NHibernate.Caches.SysCache2.SysCacheRegion: 15:29:19.764 [4] DEBUG NHibernate.Caches.SysCache2.SysCacheRegion - Fetching object 'NHibernate-Cache:Default.Entities:Domain.User, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#1d5bddf7-ef28-47dd-b61d-91d5856a2431@1668520475' from the cache.
NHibernate.Cache.NonstrictReadWriteCache: 15:29:19.764 [4] DEBUG NHibernate.Cache.NonstrictReadWriteCache - Cache hit
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - resolved object in second-level cache [Domain.User#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - creating collection wrapper:[Domain.User.roles#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - Cached Version:
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - loading [User#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - attempting to resolve [User#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - resolved object in session cache [Domain.User#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.764 [4] DEBUG NHibernate.Impl.SessionImpl - adding entity to second-level cache [Domain.Message#8]
NHibernate.Cache.NonstrictReadWriteCache: 15:29:19.764 [4] DEBUG NHibernate.Cache.NonstrictReadWriteCache - Caching: Domain.Message, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#8
NHibernate.Caches.SysCache2.SysCacheRegion: 15:29:19.780 [4] DEBUG NHibernate.Caches.SysCache2.SysCacheRegion - updating value of key 'NHibernate-Cache:Default.Entities:Domain.Message, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#8@8' to 'NHibernate.Impl.CacheEntry'.
NHibernate.Caches.SysCache2.SysCacheRegion: 15:29:19.780 [4] DEBUG NHibernate.Caches.SysCache2.SysCacheRegion - item will expire at: 07/22/2008 15:34:19
NHibernate.Impl.SessionImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.SessionImpl - done materializing entity [Domain.Message#8]
NHibernate.Impl.SessionImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.SessionImpl - initializing non-lazy collections
NHibernate.Impl.SessionImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.SessionImpl - initializing collection [Domain.User.roles#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.SessionImpl - checking second-level cache
NHibernate.Impl.SessionImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.SessionImpl - collection not cached
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - loading collection: [Domain.User.roles#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.BatcherImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands: 1
NHibernate.Impl.BatcherImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: SELECT roles0_.UserId as UserId__1_, roles0_.RoleId as RoleId1_, roles1_.RoleId as RoleId38_0_, roles1_.roleName as roleName38_0_, roles1_.loweredRoleName as loweredR3_38_0_, roles1_.description as descript4_38_0_ FROM _devel_imported.dbo.aspnet_UsersInRoles roles0_ left outer join _devel_imported.dbo.aspnet_Roles roles1_ on roles0_.RoleId=roles1_.RoleId WHERE roles0_.UserId=?
NHibernate.Type.GuidType: 15:29:19.780 [4] DEBUG NHibernate.Type.GuidType - binding '1d5bddf7-ef28-47dd-b61d-91d5856a2431' to parameter: 0
NHibernate.Loader.Loader: 15:29:19.780 [4] INFO  NHibernate.Loader.Loader - SELECT roles0_.UserId as UserId__1_, roles0_.RoleId as RoleId1_, roles1_.RoleId as RoleId38_0_, roles1_.roleName as roleName38_0_, roles1_.loweredRoleName as loweredR3_38_0_, roles1_.description as descript4_38_0_ FROM _devel_imported.dbo.aspnet_UsersInRoles roles0_ left outer join _devel_imported.dbo.aspnet_Roles roles1_ on roles0_.RoleId=roles1_.RoleId WHERE roles0_.UserId=@p0
NHibernate.SQL: 15:29:19.780 [4] DEBUG NHibernate.SQL - SELECT roles0_.UserId as UserId__1_, roles0_.RoleId as RoleId1_, roles1_.RoleId as RoleId38_0_, roles1_.roleName as roleName38_0_, roles1_.loweredRoleName as loweredR3_38_0_, roles1_.description as descript4_38_0_ FROM _devel_imported.dbo.aspnet_UsersInRoles roles0_ left outer join _devel_imported.dbo.aspnet_Roles roles1_ on roles0_.RoleId=roles1_.RoleId WHERE roles0_.UserId=@p0; @p0 = '1d5bddf7-ef28-47dd-b61d-91d5856a2431'
NHibernate.Connection.DriverConnectionProvider: 15:29:19.780 [4] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
NHibernate.Impl.BatcherImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.BatcherImpl - Opened IDataReader, open IDataReaders: 1
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - result set contains (possibly empty) collection: [Domain.User.roles#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.780 [4] DEBUG NHibernate.Impl.SessionImpl - uninitialized collection: initializing
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - processing result set
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - result set row: 0
NHibernate.Type.GuidType: 15:29:19.780 [4] DEBUG NHibernate.Type.GuidType - returning '07b29ebb-2bd3-4737-8ae1-1640c86be1e7' as column: RoleId38_0_
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - result row: 07b29ebb-2bd3-4737-8ae1-1640c86be1e7
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - Initializing object from DataReader: [Domain.roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]
NHibernate.Loader.Loader: 15:29:19.780 [4] DEBUG NHibernate.Loader.Loader - Hydrating entity: Domain.roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7
NHibernate.Type.StringType: 15:29:19.780 [4] DEBUG NHibernate.Type.StringType - returning 'uAdministrator' as column: roleName38_0_
NHibernate.Type.StringType: 15:29:19.780 [4] DEBUG NHibernate.Type.StringType - returning 'uadministrator' as column: loweredR3_38_0_
NHibernate.Type.StringType: 15:29:19.780 [4] DEBUG NHibernate.Type.StringType - returning null as column: descript4_38_0_
NHibernate.Type.GuidType: 15:29:19.780 [4] DEBUG NHibernate.Type.GuidType - returning '1d5bddf7-ef28-47dd-b61d-91d5856a2431' as column: UserId__1_
NHibernate.Loader.Loader: 15:29:19.795 [4] DEBUG NHibernate.Loader.Loader - found row of collection: [Domain.User.roles#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - reading row
NHibernate.Type.GuidType: 15:29:19.795 [4] DEBUG NHibernate.Type.GuidType - returning '07b29ebb-2bd3-4737-8ae1-1640c86be1e7' as column: RoleId1_
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - loading [roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - attempting to resolve [roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - resolved object in session cache [Domain.roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]

NHibernate.Loader.Loader: 15:29:19.795 [4] DEBUG NHibernate.Loader.Loader - done processing result set (1 rows)
NHibernate.Driver.NHybridDataReader: 15:29:19.795 [4] DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
NHibernate.Impl.BatcherImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.BatcherImpl - Closed IDataReader, open IDataReaders :0
NHibernate.Impl.BatcherImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands: 0
NHibernate.Impl.ConnectionManager: 15:29:19.795 [4] DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing database connection
NHibernate.Connection.ConnectionProvider: 15:29:19.795 [4] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
NHibernate.Loader.Loader: 15:29:19.795 [4] DEBUG NHibernate.Loader.Loader - total objects hydrated: 1
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - resolving associations for: [Domain.roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - adding entity to second-level cache [Domain.roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]
NHibernate.Cache.ReadWriteCache: 15:29:19.795 [4] DEBUG NHibernate.Cache.ReadWriteCache - Caching: Domain.roles, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#07b29ebb-2bd3-4737-8ae1-1640c86be1e7
NHibernate.Caches.SysCache2.SysCacheRegion: 15:29:19.795 [4] DEBUG NHibernate.Caches.SysCache2.SysCacheRegion - Fetching object 'NHibernate-Cache:Default.ValueObjects:Domain.roles, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#07b29ebb-2bd3-4737-8ae1-1640c86be1e7@979491179' from the cache.
NHibernate.Cache.ReadWriteCache: 15:29:19.795 [4] DEBUG NHibernate.Cache.ReadWriteCache - Item was already cached: Domain.roles, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null#07b29ebb-2bd3-4737-8ae1-1640c86be1e7
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - done materializing entity [Domain.roles#07b29ebb-2bd3-4737-8ae1-1640c86be1e7]
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - 1 collections were found in result set
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - collection fully initialized: [Domain.User.roles#1d5bddf7-ef28-47dd-b61d-91d5856a2431]
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - 1 collections initialized
NHibernate.Loader.Loader: 15:29:19.795 [4] DEBUG NHibernate.Loader.Loader - done loading collection
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - collection initialized
NHibernate.Impl.ConnectionManager: 15:29:19.795 [4] DEBUG NHibernate.Impl.ConnectionManager - after autocommit
NHibernate.Impl.ConnectionManager: 15:29:19.795 [4] DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing database connection
NHibernate.Impl.SessionImpl: 15:29:19.795 [4] DEBUG NHibernate.Impl.SessionImpl - transaction completion
NHibernate.Impl.SessionImpl: 15:29:19.811 [4] DEBUG NHibernate.Impl.SessionImpl - deleting a persistent instance
NHibernate.Impl.SessionImpl: 15:29:19.811 [4] DEBUG NHibernate.Impl.SessionImpl - deleting [Domain.Message#8]


SQL Server Profiler
I've checked through the SQL Server Profiler and it actually never shows any delete request being made. Infact it doesn't seem to get much requests at all from the code.

What I've tried already
I've tried dropping all constraints on the table in the database. I've also spend a long time searching the world wide web and tried to play around with cascade and optimistisic-locking based on articles found through google. I've also tried to capture any kind of exception being thrown and just generally playing around with the mapping file. Unfortunately I don't think I know enough yet of NHibernate to solve this and hoping I just missed something very obvious. I think it has something to do with the connection to the User who send/receives the message, but no idea how to fix it.


(ps. I've removed the actual name of the software from the Namespace. Should not have broken any code, but if it did. That's why something might look funky).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 1:01 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Can you post the code where you delete the entities ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 3:46 am 
Newbie

Joined: Tue Jul 22, 2008 10:24 am
Posts: 4
Of course, I forgot sorry.

I use a repository for the messaging center (based on a baseclass for all repositories). I have tried deleting it in two different ways. Either deleting the entity directly or through HQL. Both with no real results. (I've cleaned them up here to be without any try catch for exceptions. Those don't trigger however.

Code:
    [DataObject]
    public sealed class MessageRepository : RepositoryBase
    {

        /// <summary>
        /// Removes the a message from the internal messaging service
        /// </summary>
        /// <param name="pisaMessage"></param>
        [DataObjectMethod(DataObjectMethodType.Delete)]
        public static void Remove(Message pisaMessage)
        {
            session.Delete(Message);
        }

        /// <summary>
        /// Removes the a message from the internal messaging service based on ID of the message
        /// </summary>
        /// <param name="pisaMessageId"></param>
        [DataObjectMethod(DataObjectMethodType.Delete)]
        public static void RemoveById(int MessageId)       
        {
                session.Delete("FROM Domain.Message as Message WHERE Message.Id = ?", MessageId, NHibernateUtil.Int32);
        }

        etc...
     }



For reference the baseclass contains the session:

Code:
    public abstract class RepositoryBase
    {
        #region Protected Constants CatcheRegion
        #endregion

        #region Protected Methods (Session Manager)

        /// <summary>
        /// Returns the current NHibernate session
        /// </summary>
        protected static ISession session
        {
            [DebuggerStepThrough]
            get { return NHibernateSessionManager.Instance.GetSession(); }
        }

   etc...


Note: Normally I use an ObjectDataSource to communicate with the repository, but in this case I've tried it both through an ODS aswell as just calling the delete code manually. Both have the same effect.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 3:56 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
When do you flush the session or commit the transaction (if you use one) ? session.Delete() only "schedules" the object for deletion ! Hibernate executes the SQL not until the session is flushed (either explicitly or by a transaction.Commit).

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 5:53 am 
Newbie

Joined: Tue Jul 22, 2008 10:24 am
Posts: 4
wolli wrote:
When do you flush the session or commit the transaction (if you use one) ? session.Delete() only "schedules" the object for deletion ! Hibernate executes the SQL not until the session is flushed (either explicitly or by a transaction.Commit).


That actually is a really good question. We use an homebrew "NHibernateSessionManager" that should fire to finally commit transactions. It seems that is the actual problem (its not firing or misfiring).

When I flushed the session manually in my repository the entity did get deleted. I actually didn't know you needed to do this (as I said, still very new, I thought calling delete was enough) That SessionManager behind the scenes is something all of us mere mortal programmers here just implement as a blackbox. I did notice that manually calling for the transaction to commit didn't delete either and the SessionManager we use primarily commits transactions, it doesn't try and Flush sessions. So I guess trying to figure out why it's not working will be where I need to look (or just use a flush workaround).

At least now I know where to look, and a bit more about how NHibernate works. Your simple question helped a lot for newbie to NHibernate like myself. Many thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 6:01 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Quote:
or just use a flush workaround


I strongly recommend more investigation in your SessionManager, because flushing a session inside a running transaction (hidden in the SessionManager) might not be a good idea.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 6:34 am 
Newbie

Joined: Tue Jul 22, 2008 10:24 am
Posts: 4
wolli wrote:
Quote:
or just use a flush workaround


I strongly recommend more investigation in your SessionManager, because flushing a session inside a running transaction (hidden in the SessionManager) might not be a good idea.


I fully agree with your recommendation and already looking at it. It's just good to know if I become really desperate I can at least temp. fix it for a release. :)


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