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 LogCode:
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).