PostCommitListeners are called during rollback
----------------------------------------------
Key: HHH-6433
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6433
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.2
Environment: JDK 1.6u25, Win7, Oracle10
Reporter: Shawn Clowater
EntityActions that are registered as part of transaction completion are still called when
the transaction didn't succeed.
As an example, the DeleteEntityAction
{code}
public void doAfterTransactionCompletion(boolean success, SessionImplementor session)
throws HibernateException {
if ( getPersister().hasCache() ) {
final CacheKey ck = new CacheKey(
getId(),
getPersister().getIdentifierType(),
getPersister().getRootEntityName(),
getSession().getEntityMode(),
getSession().getFactory()
);
getPersister().getCacheAccessStrategy().unlockItem( ck, lock );
}
postCommitDelete();
}
{code}
The success is false in the event of a rollback so it doesn't update the cache but it
still calls the postCommitDelete which triggers the postCommitDelete listeners. I would
think this should only occur in the event that the transaction was actually committed.
To add insult to injury the ActionQueue will also add failed actions to the after
transaction completion queue and invalidate the query spaces.
{code}
public void execute(Executable executable) {
try {
executable.execute();
}
finally {
registerCleanupActions( executable );
}
}
private void registerCleanupActions(Executable executable) {
beforeTransactionProcesses.register( executable.getBeforeTransactionCompletionProcess()
);
if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
final String[] spaces = (String[]) executable.getPropertySpaces();
afterTransactionProcesses.addSpacesToInvalidate( spaces );
session.getFactory().getUpdateTimestampsCache().preinvalidate( spaces );
}
afterTransactionProcesses.register( executable.getAfterTransactionCompletionProcess()
);
}
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira