We audit by attaching OnPostInsert and OnPostUpdate event handlers. Inside those handlers we open a new child session and then call Save for each audit record. When the ID generator is "identity" it works fine because each call to Save immediately executes an INSERT statement to get the ID.
For performance we are using a "guid.comb" generator so that the inserts will be batched. As soon as we switched the generator records stopped being inserted. We determined that the child session was not being flushed when the parent session is flushed as part of committing the transaction.
I added the following to the Flush method in SessionImpl.cs (around line 1467) to fix the problem. Can this be incorporated back into NHibernate so I don't have to fork the project any more?
We audit by attaching OnPostInsert and OnPostUpdate event handlers. Inside those handlers we open a new child session and then call Save for each audit record. When the ID generator is "identity" it works fine because each call to Save immediately executes an INSERT statement to get the ID.
For performance we are using a "guid.comb" generator so that the inserts will be batched. As soon as we switched the generator records stopped being inserted. We determined that the child session was not being flushed when the parent session is flushed as part of committing the transaction.
I added the following to the Flush method in SessionImpl.cs (around line 1467) to fix the problem. Can this be incorporated back into NHibernate so I don't have to fork the project any more?