EmptyInterceptor example has a logical problem

Description

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

Activity

Show:

Vlad Mihalcea October 6, 2016 at 9:31 AM

We no longer maintain the 4.x branch and the latest User Guide no longer has this issue.

Steve Ebersole October 28, 2015 at 3:24 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Steve Ebersole October 27, 2015 at 7:17 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

bhuvan gupta April 1, 2014 at 8:28 AM

the problem will arise only if we are using global scope interceptor.

If we use session scope interceptor then there is no problem as for each new transaction there is a new interceptor.
Is this correct ?

bhuvan gupta March 31, 2014 at 5:57 AM

The code is also used in "JavaPersistence With Hibernate" book at page 549

Out of Date

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created March 30, 2014 at 8:32 PM
Updated December 3, 2024 at 9:19 AM
Resolved October 6, 2016 at 9:31 AM