In the example "hibernate-orm / documentation / src / main / docbook / devguide / en-US / chapters / events / extras / AuditInterceptor.java"
Due to unavailability of Transaction Id in Onsave methods , afterTransactionComplete may give falls information. Let me take a example:
Tx_A create entity EA1, EA2. Tx_B creates entity EB1, EB2.
Now let say execution flow happens this way: [1] onSave for EA1, i add EA1 id to flushList [2] onSave for EB1, i add EB1 id to flushList [3] afterTransactionComplete(tx) for Tx_A
Now at this point i will print 2 created, but actually not as EB1's transaction may rollback. may be OnSave(..) parameter should pass transaction object also.
Link to file:https://github.com/hibernate/hibernate-orm/blob/a2287b6c6d43b44f656632503401b7968c42bd86/documentation/src/main/docbook/devguide/en-US/chapters/events/extras/AuditInterceptor.java
|