no, it really does not matter which id I use. I just had to use different in one run (caching reason).
here the code and corresponding logs:
Code:
ISession session = sessionFactory.OpenSession();
ITransaction tx = session.BeginTransaction();
Event e2 = session.Load<Event>(334);
tx.Commit();
session.Close();
results in
Quote:
19.02.08 08:54:39 DEBUG - opened session
19.02.08 08:54:40 DEBUG - begin
19.02.08 08:54:40 DEBUG - Obtaining IDbConnection from Driver
19.02.08 08:54:41 DEBUG - loading [Event#334]
19.02.08 08:54:44 DEBUG - commit
19.02.08 08:54:44 DEBUG - flushing session
19.02.08 08:54:44 DEBUG - Flushing entities and processing referenced collections
19.02.08 08:54:44 DEBUG - Processing unreferenced collections
19.02.08 08:54:44 DEBUG - scheduling collection removes/(re)creates/updates
19.02.08 08:54:44 DEBUG - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
19.02.08 08:54:44 DEBUG - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
19.02.08 08:54:44 DEBUG - executing flush
19.02.08 08:54:44 DEBUG - registering flush begin
19.02.08 08:54:44 DEBUG - registering flush end
19.02.08 08:54:44 DEBUG - post flush
19.02.08 08:54:44 DEBUG - before transaction completion
19.02.08 08:54:44 DEBUG - aggressively releasing database connection
19.02.08 08:54:44 DEBUG - Closing connection
19.02.08 08:54:44 DEBUG - transaction completion
19.02.08 08:54:44 DEBUG - running AdoTransaction.Dispose()
19.02.08 08:54:44 DEBUG - closing session
19.02.08 08:54:44 DEBUG - running BatcherImpl.Dispose(true)
and
Code:
ISession session = SessionFactory.OpenSession();
try
{
string q = "from Umm.Poco.Event where Event_id = :id";
value = (T)session.CreateQuery(q).SetParameter("id", id).UniqueResult();
}
finally
{
session.Close();
}
results in
Quote:
20.02.08 08:38:00 DEBUG - opened session
20.02.08 08:38:00 DEBUG - find: from Umm.Poco.Event where Event_id = :id
20.02.08 08:38:00 DEBUG - named parameters: {id=387}
20.02.08 08:38:00 DEBUG - compiling query
20.02.08 08:38:01 DEBUG - flushing session
20.02.08 08:38:01 DEBUG - Flushing entities and processing referenced collections
20.02.08 08:38:01 DEBUG - Processing unreferenced collections
20.02.08 08:38:01 DEBUG - scheduling collection removes/(re)creates/updates
20.02.08 08:38:01 DEBUG - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
20.02.08 08:38:01 DEBUG - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
20.02.08 08:38:01 DEBUG - dont need to execute flush
20.02.08 08:38:01 DEBUG - HQL: from Umm.Poco.Event where Event_id = :id
20.02.08 08:38:01 DEBUG - SQL: select event0_.event_id as event1_1_, event0_.Event_bezeichnung as Event2_1_ from tb_umm_event event0_ where (Event_id=? )
20.02.08 08:38:01 DEBUG - Opened new IDbCommand, open IDbCommands: 1
20.02.08 08:38:01 DEBUG - Building an IDbCommand object for the SqlString: select event0_.event_id as event1_1_, event0_.Event_bezeichnung as Event2_1_ from tb_umm_event event0_ where (Event_id=? )
20.02.08 08:38:01 DEBUG - BindNamedParameters() 387 -> id [0]
20.02.08 08:38:01 DEBUG - binding '387' to parameter: 0
20.02.08 08:38:01 INFO - select event0_.event_id as event1_1_, event0_.Event_bezeichnung as Event2_1_ from tb_umm_event event0_ where (Event_id=:p0 )
20.02.08 08:38:01 DEBUG - select event0_.event_id as event1_1_, event0_.Event_bezeichnung as Event2_1_ from tb_umm_event event0_ where (Event_id=:p0 ); :p0 = '387'
20.02.08 08:38:01 DEBUG - Obtaining IDbConnection from Driver
20.02.08 08:38:01 DEBUG - Opened IDataReader, open IDataReaders: 1
20.02.08 08:38:01 DEBUG - processing result set
20.02.08 08:38:01 DEBUG - result set row: 0
20.02.08 08:38:01 DEBUG - returning '387' as column: event1_1_
20.02.08 08:38:01 DEBUG - result row: 387
20.02.08 08:38:01 DEBUG - Initializing object from DataReader: [Umm.Poco.Event#387]
20.02.08 08:38:01 DEBUG - Hydrating entity: Umm.Poco.Event#387
20.02.08 08:38:01 DEBUG - returning '2008-16' as column: Event2_1_
20.02.08 08:38:01 DEBUG - done processing result set (1 rows)
20.02.08 08:38:01 DEBUG - Closed IDataReader, open IDataReaders :0
20.02.08 08:38:01 DEBUG - Closed IDbCommand, open IDbCommands: 0
20.02.08 08:38:01 DEBUG - aggressively releasing database connection
20.02.08 08:38:01 DEBUG - Closing connection
20.02.08 08:38:01 DEBUG - total objects hydrated: 1
20.02.08 08:38:01 DEBUG - resolving associations for: [Umm.Poco.Event#387]
20.02.08 08:38:01 DEBUG - creating collection wrapper:[Umm.Poco.Event.Messages#387]
20.02.08 08:38:01 DEBUG - Entity load: Umm.Poco.Event(ID = 387)
20.02.08 08:38:01 DEBUG - done materializing entity [Umm.Poco.Event#387]
20.02.08 08:38:01 DEBUG - initializing non-lazy collections
20.02.08 08:38:01 DEBUG - after autocommit
20.02.08 08:38:01 DEBUG - aggressively releasing database connection
20.02.08 08:38:01 DEBUG - transaction completion
20.02.08 08:38:01 DEBUG - closing session
20.02.08 08:38:01 DEBUG - running BatcherImpl.Dispose(true)
Sure, I see there's a difference. But I cannot get the cause.
Only significiant difference in code is using session.CreateQuery instead of session.Load<>..