diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/attributeoverride/inheritance/TablePerClassTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/attributeoverride/inheritance/TablePerClassTest.java index c5cceec4b6..9fb1410817 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/attributeoverride/inheritance/TablePerClassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/attributeoverride/inheritance/TablePerClassTest.java @@ -21,6 +21,7 @@ import javax.persistence.Table; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.FailureExpected; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -49,10 +50,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class TablePerClassTest { @Test + @FailureExpected(reason = "@AttributeOverrides not applied for Table per class") public void testSchema(SessionFactoryScope scope) { MetadataImplementor metadata = scope.getMetadataImplementor(); - assertTrue( SchemaUtil.isColumnPresent( "DOMESTIC_CUSTOMER", "DC_address_street", metadata ) ); + assertTrue( SchemaUtil.isColumnPresent( "CUSTOMER", "STREET", metadata ) ); assertTrue( SchemaUtil.isColumnPresent( "FOREIGN_CUSTOMER", "STREET", metadata ) ); + assertTrue( SchemaUtil.isColumnPresent( "DOMESTIC_CUSTOMER", "DC_name", metadata ) ); + assertTrue( SchemaUtil.isColumnPresent( "DOMESTIC_CUSTOMER", "DC_address_street", metadata ) ); } @Test @@ -153,7 +157,8 @@ public class TablePerClassTest { @Entity(name = "Customer") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) - public static abstract class Customer { + @Table(name = "CUSTOMER") + public static class Customer { private Integer id; private String name; private Address address; diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/Address.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/Address.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/Address.java index 5451d198ef..60e57ed469 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/Address.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/Address.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.jpa.test.jointable; +package org.hibernate.orm.test.jpa.jointable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/ManyToOneJoinTableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/ManyToOneJoinTableTest.java similarity index 77% rename from hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/ManyToOneJoinTableTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/ManyToOneJoinTableTest.java index 3ddf8c6d9b..07281392b2 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/ManyToOneJoinTableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/ManyToOneJoinTableTest.java @@ -4,19 +4,22 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.jpa.test.jointable; +package org.hibernate.orm.test.jpa.jointable; import java.util.LinkedList; import org.hibernate.boot.SessionFactoryBuilder; import org.hibernate.boot.spi.MetadataImplementor; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.testing.jdbc.SQLStatementInterceptor; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.ServiceRegistry; +import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryProducer; import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertFalse; @@ -31,6 +34,12 @@ import static org.junit.Assert.assertThat; Address.class } ) +@ServiceRegistry( + settings = { + @ServiceRegistry.Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") + } +) +@SessionFactory public class ManyToOneJoinTableTest implements SessionFactoryProducer { private SQLStatementInterceptor sqlStatementInterceptor; @@ -52,7 +61,11 @@ public class ManyToOneJoinTableTest implements SessionFactoryProducer { assertThat( sqlQueries.size(), is( 1 ) ); // Ideally, we could detect that *ToOne join tables aren't used, but that requires tracking the uses of properties // Since *ToOne join tables are treated like secondary or subclass/superclass tables, the proper fix will allow many more optimizations - assertFalse( sqlQueries.getFirst().contains( "join" ) ); + String generatedSQl = sqlQueries.getFirst(); + assertFalse( + "The generated sql contains a useless join: " + generatedSQl, + generatedSQl.contains( "join" ) + ); } ); } diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/Person.java similarity index 80% rename from hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/Person.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/Person.java index 1e8104997f..c6ca1f781a 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/jointable/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/jointable/Person.java @@ -4,10 +4,14 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.jpa.test.jointable; +package org.hibernate.orm.test.jpa.jointable; -import javax.persistence.*; import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; /** * diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java index 17bd254d69..912b397ddd 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java @@ -26,7 +26,6 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.Status; import org.hibernate.stat.Statistics; -import org.hibernate.tool.schema.Action; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInterceptor;