diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java index 59bf7c049e..35d2ce984c 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java @@ -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; diff --git a/hibernate-core/src/test/java/org/hibernate/id/CreateDeleteTest.java b/hibernate-core/src/test/java/org/hibernate/id/CreateDeleteTest.java index f893fccc1b..468b511c8b 100644 --- a/hibernate-core/src/test/java/org/hibernate/id/CreateDeleteTest.java +++ b/hibernate-core/src/test/java/org/hibernate/id/CreateDeleteTest.java @@ -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