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

This commit is contained in:
Gail Badner 2018-11-06 19:03:13 -08:00
parent 22ad668b88
commit 7af7182cc1
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

@ -1844,4 +1844,8 @@ public interface CoreMessageLogger extends BasicLogger {
@LogMessage(level = WARN)
@Message(value = "The increment size of the [%s] sequence is set to [%d] in the entity mapping while the associated database sequence increment size is [%d]. The database sequence increment size will take precedence to avoid identifier allocation conflicts.", id = 497)
void sequenceIncrementSizeMismatch(String sequenceName, int incrementSize, int databaseIncrementSize);
@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);
}