From 422f8c0de41b621cc87723a297116a5d608616e8 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Tue, 20 Jun 2017 16:10:55 -0700 Subject: [PATCH] HHH-11214 : Fix test to work on pre-5.2 branches --- ...StrategyComponentCollectionRevEndTest.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyComponentCollectionRevEndTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyComponentCollectionRevEndTest.java index 55211a4e02..cd685f84cd 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyComponentCollectionRevEndTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyComponentCollectionRevEndTest.java @@ -15,6 +15,7 @@ import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Embeddable; import javax.persistence.Entity; +import javax.persistence.EntityManager; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OrderColumn; @@ -25,7 +26,6 @@ import org.hibernate.envers.strategy.ValidityAuditStrategy; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.transaction.TransactionUtil; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -56,26 +56,38 @@ public class ValidityAuditStrategyComponentCollectionRevEndTest extends BaseEnve @Priority(10) public void initData() { // Revision 1 - this.productId = TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { + EntityManager entityManager = getOrCreateEntityManager(); + entityManager.getTransaction().begin(); + { Product product = new Product( 1 , "Test" ); product.getItems().add( new Item( "bread", null ) ); entityManager.persist( product ); - return product.getId(); - } ); + this.productId = product.getId(); + } + entityManager.getTransaction().commit(); + entityManager.close(); // Revision 2 - TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { + entityManager = getOrCreateEntityManager(); + entityManager.getTransaction().begin(); + { Product product = entityManager.find( Product.class, productId ); product.getItems().add( new Item( "bread2", 2 ) ); entityManager.merge( product ); - } ); + } + entityManager.getTransaction().commit(); + entityManager.close(); // Revision 3 - TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { + entityManager = getOrCreateEntityManager(); + entityManager.getTransaction().begin(); + { Product product = entityManager.find( Product.class, productId ); product.getItems().remove( 0 ); entityManager.merge( product ); - } ); + } + entityManager.getTransaction().commit(); + entityManager.close(); } @Test