HHH-11209 : Log a DEBUG message if collection with queued operations is detached due to rollback

(cherry picked from commit 7af7182cc1)
This commit is contained in:
Gail Badner 2018-11-06 19:03:13 -08:00
parent ed55fff92b
commit cf18916444
2 changed files with 19 additions and 1 deletions

View File

@ -38,6 +38,7 @@ import org.hibernate.internal.util.collections.IdentitySet;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.resource.transaction.spi.TransactionStatus;
import org.hibernate.type.CompositeType;
import org.hibernate.type.IntegerType;
import org.hibernate.type.LongType;
@ -625,7 +626,20 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
if ( currentSession == this.session ) {
if ( !isTempSession ) {
if ( hasQueuedOperations() ) {
LOG.queuedOperationWhenDetachFromSession( MessageHelper.collectionInfoString( getRole(), getKey() ) );
final String collectionInfoString = MessageHelper.collectionInfoString( getRole(), getKey() );
final TransactionStatus transactionStatus =
session.getTransactionCoordinator().getTransactionDriverControl().getStatus();
if ( transactionStatus.isOneOf(
TransactionStatus.ROLLED_BACK,
TransactionStatus.MARKED_ROLLBACK,
TransactionStatus.FAILED_COMMIT,
TransactionStatus.FAILED_ROLLBACK,
TransactionStatus.ROLLING_BACK
) )
LOG.queuedOperationWhenDetachFromSessionOnRollback( collectionInfoString );
else {
LOG.queuedOperationWhenDetachFromSession( collectionInfoString );
}
}
this.session = null;
}

View File

@ -1826,4 +1826,8 @@ public interface CoreMessageLogger extends BasicLogger {
@LogMessage(level = WARN)
@Message(value = "Detaching an uninitialized collection with queued operations from a session: %s", id = 496)
void queuedOperationWhenDetachFromSession(String collectionInfoString);
@LogMessage(level = DEBUG)
@Message(value = "Detaching an uninitialized collection with queued operations from a session due to rollback: %s", id = 498)
void queuedOperationWhenDetachFromSessionOnRollback(String collectionInfoString);
}