HHH-13042 - Revert change made for HHH-12464.

This commit is contained in:
Chris Cranford 2018-10-22 18:15:58 -04:00 committed by Gail Badner
parent 79a8f43ba5
commit dc873c3d36
2 changed files with 1 additions and 40 deletions

View File

@ -12,7 +12,6 @@ import org.hibernate.AssertionFailure;
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
import org.hibernate.action.spi.Executable;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.service.spi.EventListenerRegistry;
@ -101,19 +100,7 @@ public abstract class EntityAction
*/
public final Serializable getId() {
if ( id instanceof DelayedPostInsertIdentifier ) {
final EntityEntry entry = session.getPersistenceContext().getEntry( instance );
if ( entry == null ) {
if ( LOG.isDebugEnabled() ) {
LOG.debugf(
"Skipping action - the persistence context does not contain any entry for the entity [%s]. This may occur if an entity is created and then deleted in the same transaction/flush.",
instance
);
}
// If an Entity is created and then deleted in the same Transaction, when Action#postDelete() calls this method the persistence context
// does not contain anymore an entry.
return null;
}
final Serializable eeId = entry.getId();
final Serializable eeId = session.getPersistenceContext().getEntry( instance ).getId();
return eeId instanceof DelayedPostInsertIdentifier ? null : eeId;
}
return id;

View File

@ -7,44 +7,20 @@
package org.hibernate.id;
import org.hibernate.FlushMode;
import org.hibernate.action.internal.EntityAction;
import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.logger.Triggerable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jboss.logging.Logger;
import static junit.framework.TestCase.assertTrue;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
@TestForIssue(jiraKey = "HHH-12464")
public class CreateDeleteTest extends BaseCoreFunctionalTestCase {
@Rule
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
Logger.getMessageLogger( CoreMessageLogger.class, EntityAction.class.getName() )
);
private Triggerable triggerable;
@Before
public void setUp() {
triggerable = logInspection.watchForLogMessages(
"Skipping action - the persistence context does not contain any entry for the entity" );
triggerable.reset();
}
@Test
@SkipForDialect(value = AbstractHANADialect.class, comment = " HANA doesn't support tables consisting of only a single auto-generated column")
public void createAndDeleteAnEntityInTheSameTransactionTest() {
@ -54,8 +30,6 @@ public class CreateDeleteTest extends BaseCoreFunctionalTestCase {
session.persist( entity );
session.delete( entity );
} );
assertTrue( triggerable.wasTriggered() );
}
@Override