jchapman wrote:
Run a trace and review the SQL which is being ran. That error occurs based on what happens at the database level. It sees that no rows are being deleted even though it executed a delete statement, and then throws an exception. I've never used FireBird so I can't really comment on the details of why that would happen. If your mapping file actually has the " in them, then that seems weird, but again that could be normal for FireBird, I wouldn't know. It also may be a bug with the FireBird dialect. Post some more details after you turn on SQL logging.
First of all tanks for your reply. Maybe you are right and somethink is wrong with the FireBird dialect. I turned the logging on. Here is the result:
Code:
2007-11-18 22:08:32,425 [10] DEBUG [NHibernate.Persister.Entity.AbstractEntityPersister] Deleting entity: [NHibernateTest.Persistence.User#2db0e09c-cda9-407c-8c04-d4d3d49664dd]
2007-11-18 22:08:32,441 [10] DEBUG [NHibernate.Impl.BatcherImpl] Opened new IDbCommand, open IDbCommands: 1
2007-11-18 22:08:32,441 [10] DEBUG [NHibernate.Impl.BatcherImpl] Building an IDbCommand object for the SqlString: DELETE FROM "Users" WHERE "LogonID" = ?
2007-11-18 22:08:32,441 [10] DEBUG [NHibernate.Type.GuidType] binding '2db0e09c-cda9-407c-8c04-d4d3d49664dd' to parameter: 0
2007-11-18 22:08:32,441 [10] DEBUG [NHibernate.SQL] DELETE FROM "Users" WHERE "LogonID" = @p0; @p0 = '2db0e09c-cda9-407c-8c04-d4d3d49664dd'
2007-11-18 22:08:32,456 [10] DEBUG [NHibernate.Impl.BatcherImpl] Closed IDbCommand, open IDbCommands: 0
2007-11-18 22:08:32,456 [10] ERROR [NHibernate.Impl.SessionImpl] could not synchronize database state with session
NHibernate.StaleStateException: Unexpected row count: 0; expected: 1
bei NHibernate.AdoNet.Expectations.BasicExpectation.VerifyOutcomeNonBatched(Int32 rowCount, IDbCommand statement)
bei NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation)
bei NHibernate.Persister.Entity.AbstractEntityPersister.Delete(Object id, Object version, Int32 j, Object obj, SqlCommandInfo sql, ISessionImplementor session, Object[] loadedState)
bei NHibernate.Persister.Entity.AbstractEntityPersister.Delete(Object id, Object version, Object obj, ISessionImplementor session)
bei NHibernate.Impl.ScheduledDeletion.Execute()
bei NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
bei NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
bei NHibernate.Impl.SessionImpl.Execute()
When I try to execute the Delete-statement manually it doesn't work. This has to be the problem. The main problem seems to be the assignment pattern in "WHERE "LogonID" = @p0; @p0 = '2db0e09c-cda9-407c-8c04-d4d3d49664dd'", the database engine doesn't understand this.
The correct statement would be:
Code:
DELETE FROM "Users" WHERE "LogonID" = '2db0e09c-cda9-407c-8c04-d4d3d49664dd'
Now I just have to find out how I can bring NHibernate to do this for me :)