9
9
import java .util .List ;
10
10
11
11
import javax .persistence .Entity ;
12
+ import javax .persistence .EntityManager ;
12
13
import javax .persistence .Id ;
13
14
import javax .persistence .Inheritance ;
14
15
import javax .persistence .InheritanceType ;
21
22
import org .junit .Test ;
22
23
23
24
import org .hibernate .testing .TestForIssue ;
24
- import org .hibernate .testing .transaction .TransactionUtil ;
25
25
26
26
import static org .junit .Assert .assertEquals ;
27
27
@@ -38,7 +38,9 @@ protected Class<?>[] getAnnotatedClasses() {
38
38
@ Test
39
39
@ Priority (10 )
40
40
public void initData () {
41
- TransactionUtil .doInJPA ( this ::entityManagerFactory , entityManager -> {
41
+ EntityManager entityManager = getOrCreateEntityManager ();
42
+ entityManager .getTransaction ().begin ();
43
+ {
42
44
final EntityC c1 = new EntityC ();
43
45
c1 .setId ( 1 );
44
46
c1 .setName ( "c1" );
@@ -52,7 +54,9 @@ public void initData() {
52
54
a1 .setRelationToC ( c1 );
53
55
a1 .setPropA ( "propC" );
54
56
entityManager .persist ( a1 );
55
- } );
57
+ }
58
+ entityManager .getTransaction ().commit ();
59
+ entityManager .close ();
56
60
}
57
61
58
62
@ Test
@@ -95,10 +99,14 @@ public void testAuditQueryWithJoinedInheritanceUnrelatedPropertyJoin() {
95
99
@ Test
96
100
public void testHibernateUnrelatedPropertyQuery () {
97
101
final String queryString = "FROM EntityA a Inner Join EntityC c ON a.propA = c.propC Where c.propB = :propB" ;
98
- TransactionUtil .doInJPA ( this ::entityManagerFactory , entityManager -> {
102
+ EntityManager entityManager = getOrCreateEntityManager ();
103
+ entityManager .getTransaction ().begin ();
104
+ {
99
105
List results = entityManager .createQuery ( queryString ).setParameter ( "propB" , "propB" ).getResultList ();
100
106
assertEquals ( 1 , results .size () );
101
- } );
107
+ }
108
+ entityManager .getTransaction ().commit ();
109
+ entityManager .close ();
102
110
}
103
111
104
112
@ Entity (name = "EntityA" )
0 commit comments