HHH-12464 - Add test for issue

This commit is contained in:
Andrea Boriero 2018-04-07 12:40:23 +01:00
parent e11d09d1dd
commit 2bf85ffd2a
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,65 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.id;
import org.hibernate.FlushMode;
import org.hibernate.action.internal.EntityAction;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
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
public void createAndDeleteAnEntityInTheSameTransactionTest() {
doInHibernate( this::sessionFactory, session -> {
session.setHibernateFlushMode( FlushMode.COMMIT );
RootEntity entity = new RootEntity();
session.persist( entity );
session.delete( entity );
} );
assertTrue( triggerable.wasTriggered() );
}
@Override
public Class[] getAnnotatedClasses() {
return new Class[] {
RootEntity.class,
RelatedEntity.class,
};
}
}

View File

@ -49,6 +49,7 @@ log4j.logger.org.hibernate.engine.internal.StatisticalLoggingSessionEventListene
log4j.logger.org.hibernate.boot.model.source.internal.hbm.ModelBinder=debug
log4j.logger.org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry=debug
log4j.logger.org.hibernate.action.internal.EntityAction=debug
log4j.logger.org.hibernate.engine.internal.Cascade=trace