From b66014b5ac4db37dcb7b035d5eaabc6221bd0e2b Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Wed, 10 May 2017 16:25:42 -0700 Subject: [PATCH] HHH-11416 : Fix test to run on pre-5.2 branches --- .../JoinedInheritancePropertyJoinTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/JoinedInheritancePropertyJoinTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/JoinedInheritancePropertyJoinTest.java index 05f546bbe6..0d8c65faca 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/JoinedInheritancePropertyJoinTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/JoinedInheritancePropertyJoinTest.java @@ -9,6 +9,7 @@ package org.hibernate.envers.test.integration.query; import java.util.List; import javax.persistence.Entity; +import javax.persistence.EntityManager; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; @@ -21,7 +22,6 @@ import org.hibernate.envers.test.Priority; import org.junit.Test; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.transaction.TransactionUtil; import static org.junit.Assert.assertEquals; @@ -38,7 +38,9 @@ public class JoinedInheritancePropertyJoinTest extends BaseEnversJPAFunctionalTe @Test @Priority(10) public void initData() { - TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { + EntityManager entityManager = getOrCreateEntityManager(); + entityManager.getTransaction().begin(); + { final EntityC c1 = new EntityC(); c1.setId( 1 ); c1.setName( "c1" ); @@ -52,7 +54,9 @@ public class JoinedInheritancePropertyJoinTest extends BaseEnversJPAFunctionalTe a1.setRelationToC( c1 ); a1.setPropA( "propC" ); entityManager.persist( a1 ); - } ); + } + entityManager.getTransaction().commit(); + entityManager.close(); } @Test @@ -95,10 +99,14 @@ public class JoinedInheritancePropertyJoinTest extends BaseEnversJPAFunctionalTe @Test public void testHibernateUnrelatedPropertyQuery() { final String queryString = "FROM EntityA a Inner Join EntityC c ON a.propA = c.propC Where c.propB = :propB"; - TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { + EntityManager entityManager = getOrCreateEntityManager(); + entityManager.getTransaction().begin(); + { List results = entityManager.createQuery( queryString ).setParameter( "propB", "propB" ).getResultList(); assertEquals( 1, results.size() ); - } ); + } + entityManager.getTransaction().commit(); + entityManager.close(); } @Entity(name = "EntityA")