sergey wrote:
This should work in 1.2.0.GA. Enable SQL logging and see what SQL is being generated.
I have enabled log4net and shows the follow logs for sql
Code:
10:53:20.954 [8] DEBUG NHibernate.Impl.SessionImpl - opened session
10:53:20.954 [8] DEBUG NHibernate.Impl.SessionImpl - loading [Department#1]
10:53:20.954 [8] DEBUG NHibernate.Impl.ConnectionManager - after autocommit
10:53:20.954 [8] DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing database connection
10:53:20.954 [8] DEBUG NHibernate.Impl.SessionImpl - transaction completion
10:53:20.954 [8] DEBUG NHibernate.Transaction.AdoTransaction - begin
10:53:20.954 [8] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
10:53:20.954 [8] DEBUG NHibernate.Impl.SessionImpl - attempting to resolve [Department#1]
10:53:20.954 [8] DEBUG NHibernate.Impl.SessionImpl - object not resolved in any cache [nhRegistration.Department#1]
10:53:20.954 [8] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Fetching entity: [nhRegistration.Department#1]
10:53:20.954 [8] DEBUG NHibernate.Loader.Loader - loading entity: [nhRegistration.Department#1]
10:53:20.954 [8] DEBUG NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands: 1
10:53:20.954 [8] DEBUG NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: SELECT department0_.Deptid as Deptid3_0_, department0_.DeptName as DeptName3_0_ FROM Department department0_ WHERE department0_.Deptid=?
10:53:20.954 [8] DEBUG NHibernate.Type.Int32Type - binding '1' to parameter: 0
10:53:20.954 [8] INFO NHibernate.Loader.Loader - SELECT department0_.Deptid as Deptid3_0_, department0_.DeptName as DeptName3_0_ FROM Department department0_ WHERE department0_.Deptid=@p0
10:53:20.954 [8] DEBUG NHibernate.SQL - SELECT department0_.Deptid as Deptid3_0_, department0_.DeptName as DeptName3_0_ FROM Department department0_ WHERE department0_.Deptid=@p0; @p0 = '1'
10:53:20.969 [8] DEBUG NHibernate.Impl.BatcherImpl - Opened IDataReader, open IDataReaders: 1
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - processing result set
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - result set row: 0
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - result row: 1
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - Initializing object from DataReader: [nhRegistration.Department#1]
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - Hydrating entity: nhRegistration.Department#1
10:53:20.969 [8] DEBUG NHibernate.Type.StringType - returning 'cs' as column: DeptName3_0_
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - done processing result set (1 rows)
10:53:20.969 [8] DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
10:53:20.969 [8] DEBUG NHibernate.Impl.BatcherImpl - Closed IDataReader, open IDataReaders :0
10:53:20.969 [8] DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands: 0
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - total objects hydrated: 1
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - resolving associations for: [nhRegistration.Department#1]
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - creating collection wrapper:[nhRegistration.Department.Classes#1]
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - creating collection wrapper:[nhRegistration.Department.Professors#1]
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - done materializing entity [nhRegistration.Department#1]
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - initializing non-lazy collections
10:53:20.969 [8] DEBUG NHibernate.Loader.Loader - done entity load
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - object already associated with session
10:53:20.969 [8] DEBUG NHibernate.Transaction.AdoTransaction - commit
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - flushing session
10:53:20.969 [8] DEBUG NHibernate.Engine.Cascades - processing cascades for: nhRegistration.Department
10:53:20.969 [8] DEBUG NHibernate.Engine.Cascades - cascading to collection: nhRegistration.Department.Classes
10:53:20.969 [8] DEBUG NHibernate.Engine.Cascades - cascading to collection: nhRegistration.Department.Professors
10:53:20.969 [8] DEBUG NHibernate.Engine.Cascades - done processing cascades for: nhRegistration.Department
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
10:53:20.969 [8] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - nhRegistration.Department.Name is dirty
10:53:20.969 [8] DEBUG NHibernate.Impl.SessionImpl - Updating entity: [nhRegistration.Department#1]
10:53:20.985 [8] DEBUG NHibernate.Impl.AbstractVisitor - Processing collection for role nhRegistration.Department.Classes
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - Collection found: [nhRegistration.Department.Classes#1], was: [nhRegistration.Department.Classes#1]
10:53:20.985 [8] DEBUG NHibernate.Impl.AbstractVisitor - Processing collection for role nhRegistration.Department.Professors
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - Collection found: [nhRegistration.Department.Professors#1], was: [nhRegistration.Department.Professors#1]
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - Processing unreferenced collections
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 2 collections
10:53:20.985 [8] DEBUG NHibernate.Impl.Printer - listing entities:
10:53:20.985 [8] DEBUG NHibernate.Impl.Printer - nhRegistration.Department{Classes=uninitialized, Name=transaction test app, Professors=uninitialized, Id=1}
10:53:20.985 [8] DEBUG NHibernate.Impl.SessionImpl - executing flush
10:53:20.985 [8] DEBUG NHibernate.Impl.ConnectionManager - registering flush begin
10:53:21.001 [8] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Updating entity: [nhRegistration.Department#1]
10:53:21.001 [8] DEBUG NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands: 1
10:53:21.001 [8] DEBUG NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: UPDATE Department SET DeptName = ? WHERE Deptid = ?
10:53:21.001 [8] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Dehydrating entity: [nhRegistration.Department#1]
10:53:21.001 [8] DEBUG NHibernate.Type.StringType - binding 'transaction test app' to parameter: 0
10:53:21.001 [8] DEBUG NHibernate.Type.Int32Type - binding '1' to parameter: 1
10:53:21.001 [8] DEBUG NHibernate.SQL - UPDATE Department SET DeptName = @p0 WHERE Deptid = @p1; @p0 = 'transaction test app', @p1 = '1'
10:53:21.001 [8] DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands: 0
10:53:21.001 [8] DEBUG NHibernate.Impl.ConnectionManager - registering flush end
10:53:21.001 [8] DEBUG NHibernate.Impl.SessionImpl - post flush
10:53:21.001 [8] DEBUG NHibernate.Impl.SessionImpl - before transaction completion
10:53:21.016 [8] DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing database connection
10:53:21.016 [8] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
10:53:21.016 [8] DEBUG NHibernate.Impl.SessionImpl - transaction completion
10:53:21.016 [8] DEBUG NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()
10:53:21.016 [8] DEBUG NHibernate.Impl.SessionImpl - closing session
10:53:21.016 [8] DEBUG NHibernate.Impl.BatcherImpl - running BatcherImpl.Dispose(true)
Is it true that this log:
NHibernate.Transaction.AdoTransaction - begin
begin the transaction? However, it seems the same for different isolation level and the sql server is not really lock for the record for update
Thanks.