Now that I'm back at my desk, here is more of the requested info:
Hibernate version: v2.0.1GA
Mapping documents: (provided above)
Code between sessionFactory.openSession() and session.close():
Code:
using(ISession session = OpenSession())
using (ITransaction tx = session.BeginTransaction())
{
session.Update(entity);
session.Flush(); // thought this might delete the orphans
tx.Commit();
}
Full stack trace of any exception that occurs:
No exception, expected behavior just doesn't happen.
Name and version of the database you are using:
MS SQL 2005
The generated SQL (show_sql=true):
ICollectionPersister Static SQL for collection: MyAssembly.Entity.Aliases
ICollectionPersister Row insert: UPDATE EntityAlias SET EntityID = ? WHERE ID = ?
ICollectionPersister Row delete: UPDATE EntityAlias SET EntityID = null WHERE EntityID = ? AND ID = ?
ICollectionPersister One-shot delete: UPDATE EntityAlias SET EntityID = null WHERE EntityID = ?
AbstractEntityPersister Version select: SELECT ID FROM Entity WHERE ID = ?
AbstractEntityPersister Snapshot select: SELECT entity_.ID, entity_.Name as Name1_ FROM Entity entity_ WHERE entity_.ID=?
Debug level Hibernate log excerpt:
] NHibernate.SQL UPDATE Entity SET Name = @p1 WHERE ID = @p2; @p1 = 'Test Entity', @p2 = '992'
2009-01-22 17:08:09,977 DEBUG [8 ] Transaction.AdoTransaction Enlist Command
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Closed IDbCommand, open IDbCommands: 0
2009-01-22 17:08:09,977 DEBUG [8 ] Collection.ICollectionPersister Deleting collection: [MyAssembly.Entity.Aliases#992]
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Opened new IDbCommand, open IDbCommands: 1
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Building an IDbCommand object for the SqlString: UPDATE EntityAlias SET EntityID = null WHERE EntityID = ?
2009-01-22 17:08:09,977 DEBUG [8 ] Type.Int32Type binding '992' to parameter: 0
2009-01-22 17:08:09,977 DEBUG [8 ] NHibernate.SQL UPDATE EntityAlias SET EntityID = null WHERE EntityID = @p0; @p0 = '992'
2009-01-22 17:08:09,977 DEBUG [8 ] Transaction.AdoTransaction Enlist Command
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Closed IDbCommand, open IDbCommands: 0
2009-01-22 17:08:09,977 DEBUG [8 ] Collection.ICollectionPersister done deleting collection
2009-01-22 17:08:09,977 DEBUG [8 ] Collection.ICollectionPersister Inserting collection: [MyAssembly.Entity.Aliases#992]
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Opened new IDbCommand, open IDbCommands: 1
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Building an IDbCommand object for the SqlString: UPDATE EntityAlias SET EntityID = ? WHERE ID = ?
2009-01-22 17:08:09,977 DEBUG [8 ] Type.Int32Type binding '992' to parameter: 0
2009-01-22 17:08:09,977 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:09,977 DEBUG [8 ] Type.Int32Type binding '41' to parameter: 1
2009-01-22 17:08:09,977 DEBUG [8 ] NHibernate.SQL UPDATE EntityAlias SET EntityID = @p0 WHERE ID = @p1; @p0 = '992', @p1 = '41'
2009-01-22 17:08:09,977 DEBUG [8 ] Transaction.AdoTransaction Enlist Command
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher reusing command UPDATE EntityAlias SET EntityID = @p0 WHERE ID = @p1
2009-01-22 17:08:09,977 DEBUG [8 ] Type.Int32Type binding '992' to parameter: 0
2009-01-22 17:08:09,977 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:09,977 DEBUG [8 ] Type.Int32Type binding '47' to parameter: 1
2009-01-22 17:08:09,977 DEBUG [8 ] NHibernate.SQL UPDATE EntityAlias SET EntityID = @p0 WHERE ID = @p1; @p0 = '992', @p1 = '47'
2009-01-22 17:08:09,977 DEBUG [8 ] Transaction.AdoTransaction Enlist Command
2009-01-22 17:08:09,977 DEBUG [8 ] Collection.ICollectionPersister done inserting collection: 2 rows inserted
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.AbstractBatcher Closed IDbCommand, open IDbCommands: 0
2009-01-22 17:08:09,977 DEBUG [8 ] AdoNet.ConnectionManager registering flush end
2009-01-22 17:08:09,992 DEBUG [8 ] Default.AbstractFlushingEventListener post flush
2009-01-22 17:08:09,992 DEBUG [8 ] Transaction.AdoTransaction Start Commit
2009-01-22 17:08:09,992 DEBUG [8 ] Default.AbstractFlushingEventListener flushing session
2009-01-22 17:08:09,992 DEBUG [8 ] Default.AbstractFlushingEventListener processing flush-time cascades
2009-01-22 17:08:09,992 INFO [8 ] Engine.Cascade processing cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for: MyAssembly.Entity
2009-01-22 17:08:09,992 INFO [8 ] Engine.Cascade deleting orphans for collection: MyAssembly.Entity.Aliases
2009-01-22 17:08:10,008 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:10,008 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:10,008 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:10,008 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:10,008 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:10,008 DEBUG [8 ] Engine.IdentifierValue unsaved-value: 0
2009-01-22 17:08:10,008 INFO [8 ] Engine.Cascade done deleting orphans for collection: MyAssembly.Entity.Aliases
2009-01-22 17:08:10,008 INFO [8 ] Engine.Cascade done processing cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for: MyAssembly.Entity
2009-01-22 17:08:10,008 DEBUG [8 ] Default.AbstractFlushingEventListener dirty checking collections
2009-01-22 17:08:10,008 DEBUG [8 ] Default.AbstractFlushingEventListener Flushing entities and processing referenced collections
2009-01-22 17:08:10,024 DEBUG [8 ] Engine.Collections Collection found: [MyAssembly.Entity.Aliases#992], was: [MyAssembly.Entity.Aliases#992] (initialized)
2009-01-22 17:08:10,024 DEBUG [8 ] Default.AbstractFlushingEventListener Processing unreferenced collections
2009-01-22 17:08:10,024 DEBUG [8 ] Default.AbstractFlushingEventListener Scheduling collection removes/(re)creates/updates
2009-01-22 17:08:10,024 DEBUG [8 ] Default.AbstractFlushingEventListener Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
2009-01-22 17:08:10,024 DEBUG [8 ] Default.AbstractFlushingEventListener Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
2009-01-22 17:08:10,024 DEBUG [8 ] Impl.Printer listing entities:
2009-01-22 17:08:10,024 DEBUG [8 ] Impl.Printer MyAssembly.Entity{Names=[MyAssembly.EntityAlias#41, MyAssembly.EntityAlias#47], Name=Test Entity, ID=992}
2009-01-22 17:08:10,024 DEBUG [8 ] Default.AbstractFlushingEventListener executing flush
2009-01-22 17:08:10,024 DEBUG [8 ] AdoNet.ConnectionManager registering flush begin
2009-01-22 17:08:10,024 DEBUG [8 ] AdoNet.ConnectionManager registering flush end
2009-01-22 17:08:10,024 DEBUG [8 ] Default.AbstractFlushingEventListener post flush
2009-01-22 17:08:10,024 DEBUG [8 ] Impl.SessionImpl before transaction completion
2009-01-22 17:08:10,055 DEBUG [8 ] Transaction.AdoTransaction IDbTransaction Committed
2009-01-22 17:08:10,055 DEBUG [8 ] Impl.SessionImpl transaction completion
2009-01-22 17:08:10,055 DEBUG [8 ] AdoNet.ConnectionManager aggressively releasing database connection
2009-01-22 17:08:10,055 DEBUG [8 ] Connection.ConnectionProvider Closing connection
2009-01-22 17:08:10,055 DEBUG [8 ] Transaction.AdoTransaction IDbTransaction disposed.
2009-01-22 17:08:10,055 DEBUG [8 ] Impl.SessionImpl running ISession.Dispose()
2009-01-22 17:08:10,055 DEBUG [8 ] Impl.SessionImpl closing session
2009-01-22 17:08:10,055 DEBUG [8 ] AdoNet.AbstractBatcher running BatcherImpl.Dispose(true)
[Session Ended]