|
4 | 4 | */ |
5 | 5 | package org.hibernate.orm.test.annotations.secondarytable; |
6 | 6 |
|
7 | | -import java.io.Serializable; |
8 | | -import java.util.List; |
9 | | -import java.util.Map; |
10 | 7 | import jakarta.persistence.Column; |
11 | 8 | import jakarta.persistence.Entity; |
12 | 9 | import jakarta.persistence.Id; |
13 | 10 | import jakarta.persistence.PrimaryKeyJoinColumn; |
14 | 11 | import jakarta.persistence.SecondaryTable; |
15 | 12 | import jakarta.persistence.Table; |
16 | | - |
17 | 13 | import org.hibernate.annotations.DynamicUpdate; |
18 | 14 | import org.hibernate.annotations.OptimisticLockType; |
19 | 15 | import org.hibernate.annotations.OptimisticLocking; |
20 | 16 | import org.hibernate.annotations.SecondaryRow; |
21 | 17 | import org.hibernate.cfg.AvailableSettings; |
22 | 18 | import org.hibernate.dialect.H2Dialect; |
23 | | -import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; |
| 19 | +import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest; |
| 20 | +import org.hibernate.testing.orm.junit.RequiresDialect; |
| 21 | +import org.junit.jupiter.api.Test; |
24 | 22 |
|
25 | | -import org.hibernate.testing.RequiresDialect; |
26 | | -import org.junit.Test; |
| 23 | +import java.util.List; |
| 24 | +import java.util.Map; |
| 25 | + |
| 26 | +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; |
27 | 27 |
|
28 | | -import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; |
29 | | -import static org.junit.Assert.assertTrue; |
30 | 28 |
|
31 | 29 | /** |
32 | 30 | * @author Vlad Mihalcea |
33 | 31 | */ |
34 | 32 | @RequiresDialect(value = H2Dialect.class) |
35 | | -public class SecondaryTableSchemaTest |
36 | | - extends BaseEntityManagerFunctionalTestCase { |
| 33 | +public class SecondaryTableSchemaTest extends EntityManagerFactoryBasedFunctionalTest { |
| 34 | + |
37 | 35 |
|
38 | 36 | @Override |
39 | 37 | protected Class<?>[] getAnnotatedClasses() { |
40 | | - return new Class<?>[] { |
41 | | - Cluster.class, |
42 | | - }; |
| 38 | + return new Class[] {Cluster.class}; |
43 | 39 | } |
44 | 40 |
|
45 | 41 | protected void addConfigOptions(Map options) { |
46 | 42 | options.put( |
47 | | - AvailableSettings.URL, |
48 | | - options.get( AvailableSettings.URL ) + ";INIT=CREATE SCHEMA IF NOT EXISTS schema1\\;CREATE SCHEMA IF NOT EXISTS schema2;" |
| 43 | + AvailableSettings.URL, |
| 44 | + options.get( AvailableSettings.URL ) |
| 45 | + + ";INIT=CREATE SCHEMA IF NOT EXISTS schema1\\;CREATE SCHEMA IF NOT EXISTS schema2;" |
49 | 46 | ); |
50 | 47 | } |
51 | 48 |
|
52 | 49 | @Test |
53 | 50 | public void test() { |
54 | | - doInJPA( this::entityManagerFactory, entityManager -> { |
55 | | - List<Cluster> clusters = entityManager.createQuery( "select c from Cluster c" ).getResultList(); |
| 51 | + inTransaction( entityManager -> { |
| 52 | + List<Cluster> clusters = entityManager.createQuery( "select c from Cluster c", Cluster.class ) |
| 53 | + .getResultList(); |
56 | 54 |
|
57 | | - assertTrue(clusters.isEmpty()); |
| 55 | + assertThat( clusters.isEmpty() ).isTrue(); |
58 | 56 | } ); |
59 | 57 | } |
60 | 58 |
|
61 | 59 | @Entity(name = "Cluster") |
62 | 60 | @Table(name = "cluster", schema = "schema1") |
63 | | - @SecondaryTable(name = "Cluster", schema="schema2", pkJoinColumns = { @PrimaryKeyJoinColumn(name = "clusterid") }) |
| 61 | + @SecondaryTable(name = "Cluster", schema = "schema2", pkJoinColumns = {@PrimaryKeyJoinColumn(name = "clusterid")}) |
64 | 62 | @SecondaryRow(table = "Cluster", optional = false) |
65 | 63 | @OptimisticLocking(type = OptimisticLockType.DIRTY) |
66 | 64 | @DynamicUpdate |
67 | | - public static class Cluster implements Serializable { |
68 | | - private static final long serialVersionUID = 3965099001305947412L; |
| 65 | + public static class Cluster { |
69 | 66 |
|
70 | 67 | @Id |
71 | 68 | @Column(name = "objid") |
|
0 commit comments