From b06be7ff6d47735594c39295e5030f3e4a975048 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Sun, 12 Jul 2020 13:05:18 +0100 Subject: [PATCH] Re-enabled additional tests --- .../genericsinheritance/Child.java | 2 +- .../genericsinheritance/ChildHierarchy1.java | 2 +- .../genericsinheritance/ChildHierarchy2.java | 2 +- .../genericsinheritance/ChildHierarchy22.java | 2 +- .../GenericsInheritanceTest.java | 32 +++ .../genericsinheritance/Parent.java | 2 +- .../genericsinheritance/ParentHierarchy1.java | 2 +- .../genericsinheritance/ParentHierarchy2.java | 2 +- .../ParentHierarchy22.java | 2 +- .../discriminatoroptions/BaseClass.java | 2 +- .../discriminatoroptions/BaseClass2.java | 2 +- .../DiscriminatorOptionsTest.java | 28 +- .../discriminatoroptions/SubClass.java | 2 +- .../discriminatoroptions/SubClass2.java | 2 +- .../inheritance/joined/Account.java | 85 ++++++ .../annotations/inheritance/joined/Alarm.java | 47 ++++ .../annotations/inheritance/joined/Asset.java | 48 ++++ .../inheritance/joined/Client.java | 70 +++++ .../inheritance/joined/Clothing.java | 55 ++++ .../inheritance/joined/Company.java | 50 ++++ .../inheritance/joined/Customer.java | 46 ++++ .../inheritance/joined/Document.java | 40 +++ .../inheritance/joined/EventInformation.java | 45 +++ .../annotations/inheritance/joined/File.java | 55 ++++ .../inheritance/joined/FinancialAsset.java | 27 ++ .../inheritance/joined/Folder.java | 38 +++ .../joined/JoinedSubclassTest.java | 257 ++++++++++++++++++ .../inheritance/joined/LegalEntity.java | 35 +++ .../inheritance/joined/Parent.java | 56 ++++ .../inheritance/joined/Person.java | 58 ++++ .../annotations/inheritance/joined/Pool.java | 71 +++++ .../inheritance/joined/PoolAddress.java | 24 ++ .../inheritance/joined/ProgramExecution.java | 54 ++++ .../inheritance/joined/PropertyAsset.java | 27 ++ .../inheritance/joined/Sweater.java | 29 ++ .../inheritance/joined/SwimmingPool.java | 18 ++ .../inheritance/joined/SymbolicLink.java | 36 +++ .../inheritance/mixed/Document.java | 2 +- .../annotations/inheritance/mixed/File.java | 2 +- .../annotations/inheritance/mixed/Folder.java | 2 +- .../inheritance/mixed/SubclassTest.java | 60 ++-- .../inheritance/mixed/SymbolicLink.java | 2 +- .../inheritance/singletable/Building.java | 2 +- .../DuplicatedDiscriminatorValueTest.java | 22 +- .../inheritance/singletable/Funk.java | 2 +- .../inheritance/singletable/House.java | 2 +- .../inheritance/singletable/Music.java | 2 +- .../inheritance/singletable/Noise.java | 2 +- .../inheritance/singletable/PaperTrash.java | 2 +- .../inheritance/singletable/Rock.java | 2 +- .../inheritance/singletable/Trash.java | 2 +- .../inheritance/union/Document.java | 3 +- .../annotations/inheritance/union/File.java | 3 +- .../annotations/inheritance/union/Folder.java | 3 +- .../inheritance/union/SubclassTest.java | 48 ++-- .../inheritance/union/SymbolicLink.java | 3 +- .../test}/subclassProxyInterface/Doctor.java | 2 +- .../test}/subclassProxyInterface/IDoctor.java | 2 +- .../subclassProxyInterface/Person.hbm.xml | 2 +- .../test}/subclassProxyInterface/Person.java | 2 +- .../SubclassProxyInterfaceTest.java | 9 +- .../GenericsInheritanceTest.java | 34 --- .../annotations/inheritance/SubclassTest.java | 8 +- .../inheritance/joined/Account.java | 2 +- .../annotations/inheritance/joined/Alarm.java | 1 + .../annotations/inheritance/joined/Asset.java | 1 + .../inheritance/joined/Client.java | 4 +- .../inheritance/joined/Clothing.java | 1 + .../inheritance/joined/Company.java | 1 + .../inheritance/joined/Customer.java | 2 +- .../inheritance/joined/Document.java | 1 + .../inheritance/joined/EventInformation.java | 1 + .../annotations/inheritance/joined/File.java | 1 + .../inheritance/joined/FinancialAsset.java | 1 + .../inheritance/joined/Folder.java | 1 + .../JoinedSubclassAndSecondaryTable.java | 180 ++++++------ .../joined/JoinedSubclassTest.java | 242 ----------------- .../inheritance/joined/LegalEntity.java | 2 +- .../inheritance/joined/Parent.java | 1 + .../inheritance/joined/Person.java | 2 +- .../annotations/inheritance/joined/Pool.java | 1 + .../inheritance/joined/ProgramExecution.java | 1 + .../inheritance/joined/PropertyAsset.java | 1 + .../inheritance/joined/Sweater.java | 1 + .../inheritance/joined/SwimmingPool.java | 1 + .../inheritance/joined/SymbolicLink.java | 1 + 86 files changed, 1540 insertions(+), 490 deletions(-) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/Child.java (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/ChildHierarchy1.java (84%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/ChildHierarchy2.java (85%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/ChildHierarchy22.java (84%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/GenericsInheritanceTest.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/Parent.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/ParentHierarchy1.java (84%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/ParentHierarchy2.java (85%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/genericsinheritance/ParentHierarchy22.java (84%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/discriminatoroptions/BaseClass.java (89%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/discriminatoroptions/BaseClass2.java (87%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java (75%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/discriminatoroptions/SubClass.java (85%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/discriminatoroptions/SubClass2.java (84%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Account.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Alarm.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Asset.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Client.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Clothing.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Company.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Customer.java create mode 100755 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Document.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/EventInformation.java create mode 100755 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/File.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/FinancialAsset.java create mode 100755 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Folder.java create mode 100755 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/JoinedSubclassTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/LegalEntity.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Parent.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Person.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Pool.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PoolAddress.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/ProgramExecution.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PropertyAsset.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Sweater.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SwimmingPool.java create mode 100755 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SymbolicLink.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/mixed/Document.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/mixed/File.java (95%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/mixed/Folder.java (92%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/mixed/SubclassTest.java (71%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/mixed/SymbolicLink.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/Building.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.java (79%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/Funk.java (89%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/House.java (86%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/Music.java (95%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/Noise.java (86%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/PaperTrash.java (84%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/Rock.java (86%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/singletable/Trash.java (90%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/union/Document.java (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/union/File.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/union/Folder.java (92%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/union/SubclassTest.java (67%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/annotations/inheritance/union/SymbolicLink.java (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm/test}/subclassProxyInterface/Doctor.java (89%) rename hibernate-core/src/test/java/org/hibernate/{ => orm/test}/subclassProxyInterface/IDoctor.java (85%) rename hibernate-core/src/test/java/org/hibernate/{ => orm/test}/subclassProxyInterface/Person.hbm.xml (90%) rename hibernate-core/src/test/java/org/hibernate/{ => orm/test}/subclassProxyInterface/Person.java (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm/test}/subclassProxyInterface/SubclassProxyInterfaceTest.java (81%) delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java delete mode 100755 hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/Child.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/Child.java similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/Child.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/Child.java index 2233047d66..d507340a00 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/Child.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/Child.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.MappedSuperclass; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy1.java similarity index 84% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy1.java index c390f750d2..935cce387e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy1.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy1.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.Entity; @Entity diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy2.java similarity index 85% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy2.java index 942a3a5ed7..ecc64dcf5c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy2.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy2.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.MappedSuperclass; @MappedSuperclass diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy22.java similarity index 84% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy22.java index 6f2f0ec2d5..2175156f72 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ChildHierarchy22.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ChildHierarchy22.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.Entity; @Entity diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/GenericsInheritanceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/GenericsInheritanceTest.java new file mode 100644 index 0000000000..3ca50a1922 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/GenericsInheritanceTest.java @@ -0,0 +1,32 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.genericsinheritance; + +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +/** + * @author Emmanuel Bernard + */ +@DomainModel(annotatedClasses = { + ChildHierarchy1.class, + ParentHierarchy1.class, + ChildHierarchy22.class, + ParentHierarchy22.class +}) +@SessionFactory +public class GenericsInheritanceTest { + @Test + public void testMapping(SessionFactoryScope scope) { + scope.inSession( sessionImplementor -> { + //mapping is tested + } ); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/Parent.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/Parent.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/Parent.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/Parent.java index 2d7e2ef7da..e27b62a464 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/Parent.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/Parent.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import java.util.HashMap; import java.util.Map; import javax.persistence.GeneratedValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy1.java similarity index 84% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy1.java index 9c47b28998..65d6b09836 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy1.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy1.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.Entity; @Entity diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy2.java similarity index 85% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy2.java index 78bee21989..0043f2af5d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy2.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy2.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.MappedSuperclass; @MappedSuperclass diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy22.java similarity index 84% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy22.java index f0c47a2257..907bcc50e0 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/ParentHierarchy22.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/genericsinheritance/ParentHierarchy22.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.test.annotations.genericsinheritance; +package org.hibernate.orm.test.annotations.genericsinheritance; import javax.persistence.Entity; @Entity diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/BaseClass.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/BaseClass.java similarity index 89% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/BaseClass.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/BaseClass.java index 5ab592a778..0fd31fa9eb 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/BaseClass.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/BaseClass.java @@ -6,7 +6,7 @@ */ // $Id$ -package org.hibernate.test.annotations.inheritance.discriminatoroptions; +package org.hibernate.orm.test.annotations.inheritance.discriminatoroptions; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/BaseClass2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/BaseClass2.java similarity index 87% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/BaseClass2.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/BaseClass2.java index 5ebda02f7d..14c677c042 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/BaseClass2.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/BaseClass2.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.test.annotations.inheritance.discriminatoroptions; +package org.hibernate.orm.test.annotations.inheritance.discriminatoroptions; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java similarity index 75% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java index 6a83c77390..555688616f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.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.test.annotations.inheritance.discriminatoroptions; +package org.hibernate.orm.test.annotations.inheritance.discriminatoroptions; import org.hibernate.boot.Metadata; import org.hibernate.boot.MetadataSources; @@ -13,21 +13,21 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.RootClass; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import org.hibernate.testing.junit5.BaseUnitTest; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static junit.framework.TestCase.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the @DiscriminatorOptions annotations. * * @author Hardy Ferentschik */ -public class DiscriminatorOptionsTest extends BaseUnitTestCase { +public class DiscriminatorOptionsTest extends BaseUnitTest { @Test - public void testNonDefaultOptions() throws Exception { + public void testNonDefaultOptions() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { @@ -41,7 +41,7 @@ public class DiscriminatorOptionsTest extends BaseUnitTestCase { assertTrue( persistentClass instanceof RootClass ); RootClass root = (RootClass) persistentClass; - assertTrue( "Discriminator should be forced", root.isForceDiscriminator() ); + assertTrue( root.isForceDiscriminator(), "Discriminator should be forced" ); assertFalse( "Discriminator should not be insertable", root.isDiscriminatorInsertable() ); } finally { @@ -50,7 +50,7 @@ public class DiscriminatorOptionsTest extends BaseUnitTestCase { } @Test - public void testBaseline() throws Exception { + public void testBaseline() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { @@ -63,7 +63,7 @@ public class DiscriminatorOptionsTest extends BaseUnitTestCase { assertNotNull( persistentClass ); assertTrue( persistentClass instanceof RootClass ); - RootClass root = ( RootClass ) persistentClass; + RootClass root = (RootClass) persistentClass; assertFalse( "Discriminator should not be forced by default", root.isForceDiscriminator() ); } finally { @@ -72,7 +72,7 @@ public class DiscriminatorOptionsTest extends BaseUnitTestCase { } @Test - public void testPropertyBasedDiscriminatorForcing() throws Exception { + public void testPropertyBasedDiscriminatorForcing() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); try { @@ -87,8 +87,8 @@ public class DiscriminatorOptionsTest extends BaseUnitTestCase { assertNotNull( persistentClass ); assertTrue( persistentClass instanceof RootClass ); - RootClass root = ( RootClass ) persistentClass; - assertTrue( "Discriminator should be forced by property", root.isForceDiscriminator() ); + RootClass root = (RootClass) persistentClass; + assertTrue( root.isForceDiscriminator(), "Discriminator should be forced by property" ); } finally { StandardServiceRegistryBuilder.destroy( ssr ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/SubClass.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/SubClass.java similarity index 85% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/SubClass.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/SubClass.java index b811416d20..5d43a8ad8a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/SubClass.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/SubClass.java @@ -6,7 +6,7 @@ */ // $Id$ -package org.hibernate.test.annotations.inheritance.discriminatoroptions; +package org.hibernate.orm.test.annotations.inheritance.discriminatoroptions; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/SubClass2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/SubClass2.java similarity index 84% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/SubClass2.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/SubClass2.java index 1d0fc82574..98fe62250f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/SubClass2.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/discriminatoroptions/SubClass2.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.test.annotations.inheritance.discriminatoroptions; +package org.hibernate.orm.test.annotations.inheritance.discriminatoroptions; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Account.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Account.java new file mode 100644 index 0000000000..ac4a6046dc --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Account.java @@ -0,0 +1,85 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name = "`ACCOUNT`") +public class Account implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue + private int id; + + @Column(name="fld_number") + private String number; + + @OneToMany(mappedBy="account") + private Set clients; + + private double balance; + + public Account() { + } + + public int getId() { + return this.id; + } + + @SuppressWarnings("unused") + private void setId(int id) { + this.id = id; + } + + public String getNumber() { + return this.number; + } + + public void setNumber(String number) { + this.number = number; + } + + public double getBalance() { + return balance; + } + + public void setBalance(double balance) { + this.balance = balance; + } + + public void addClient(Client c) { + if (clients == null) { + clients = new HashSet(); + } + clients.add(c); + c.setAccount(this); + } + + + public Set getClients() { + return clients; + } + + public void setClients(Set clients) { + this.clients = clients; + } + + + + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Alarm.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Alarm.java new file mode 100644 index 0000000000..d5d27e7313 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Alarm.java @@ -0,0 +1,47 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.OneToOne; + +@Entity +@DiscriminatorValue("AlarmT") +public class Alarm extends EventInformation { + + protected EventInformation eventInfo; + + @OneToOne + @JoinColumns({@JoinColumn(name = "EVENTINFO_NOTIFICATIONID", + referencedColumnName = "NOTIFICATIONID")}) + public EventInformation getEventInfo() { + return eventInfo; + } + + public void setEventInfo(EventInformation value) { + this.eventInfo = value; + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + String eventId = ( getEventInfo() != null ? + getEventInfo().getNotificationId() : null ); + sb.append( + "AlarmT: id = " + getNotificationId() + "\t" + + "has event id = " + eventId + ); + return sb.toString(); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Asset.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Asset.java new file mode 100644 index 0000000000..b0acc599f0 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Asset.java @@ -0,0 +1,48 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +@Table(name = "TBLASSET") +public class Asset { + private Integer id; + + private Parent parent = null; + + @Id @GeneratedValue public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @ManyToOne(targetEntity = Parent.class) + @JoinColumn(name = "PARENTID") + public Parent getParent() { + return parent; + } + + public void setParent(Parent parent) { + this.parent = parent; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Client.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Client.java new file mode 100644 index 0000000000..82d1f42779 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Client.java @@ -0,0 +1,70 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "CLIENT") +public class Client extends Person implements Serializable { + private static final long serialVersionUID = 1L; + + private String street; + + private String code; + + private String city; + + @ManyToOne(fetch = FetchType.EAGER) + @JoinTable(name = "CLIENT_ACCOUNT", + joinColumns = {@JoinColumn(name = "FK_CLIENT", referencedColumnName = "ID")}, + inverseJoinColumns = {@JoinColumn(name = "FK_ACCOUNT", referencedColumnName = "ID")}) + private Account account; + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } + + public Client() { + super(); + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Clothing.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Clothing.java new file mode 100644 index 0000000000..485e8e31d3 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Clothing.java @@ -0,0 +1,55 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + +/** + * @author Emmanuel Bernard + */ +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +public abstract class Clothing { + private long id; + private int size; + private String color; + + @Id + @GeneratedValue + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "cloth_size") + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Company.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Company.java new file mode 100644 index 0000000000..807805a302 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Company.java @@ -0,0 +1,50 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; + +/** + * @author Sharath Reddy + * + */ +@Entity +@Table(name = "Company") +@SecondaryTable(name = "CompanyAddress") +public class Company extends Customer { + + private String companyName; + private String companyAddress; + + @Column + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + @Column(table = "CompanyAddress") + public String getCompanyAddress() { + return companyAddress; + } + + public void setCompanyAddress(String companyAddress) { + this.companyAddress = companyAddress; + } + + + + + + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Customer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Customer.java new file mode 100644 index 0000000000..6c6825f4dd --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Customer.java @@ -0,0 +1,46 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.SecondaryTable; +import javax.persistence.Table; + +/** + * @author Sharath Reddy + * + */ +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +@Table(name = "Customer") +@SecondaryTable(name = "CustomerDetails") +public class Customer extends LegalEntity { + + public String customerName; + public String customerCode; + + @Column + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String val) { + this.customerName = val; + } + + @Column(table="CustomerDetails") + public String getCustomerCode() { + return customerCode; + } + + public void setCustomerCode(String val) { + this.customerCode = val; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Document.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Document.java new file mode 100755 index 0000000000..282923dbbc --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Document.java @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Entity; + +import org.hibernate.annotations.ForeignKey; + +/** + * @author Emmanuel Bernard + */ +@Entity +@ForeignKey(name = "FK_DOCU_FILE") +public class Document extends File { + @Column(nullable = false, name="xsize") + private int size; + + Document() { + } + + Document(String name, int size) { + super( name ); + this.size = size; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/EventInformation.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/EventInformation.java new file mode 100644 index 0000000000..e08c354e71 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/EventInformation.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; + + +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING, length = 80) +@DiscriminatorValue("EventInformationT") +public class EventInformation implements java.io.Serializable { + + + protected String notificationId; + + @Id + public String getNotificationId() { + return notificationId; + } + + public void setNotificationId(String value) { + this.notificationId = value; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append( "EventInformationT: id = " + getNotificationId() ); + return sb.toString(); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/File.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/File.java new file mode 100755 index 0000000000..f9bdd8b37f --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/File.java @@ -0,0 +1,55 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +@Table(name="joined_file") +public abstract class File { + @Id @Column(name="filename") + private String name; + @ManyToOne + private Folder parent; + + File() { + } + + public File(String name) { + this.name = name; + } + + + public String getName() { + return name; + } + + public void setName(String id) { + this.name = id; + } + + public Folder getParent() { + return parent; + } + + public void setParent(Folder parent) { + this.parent = parent; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/FinancialAsset.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/FinancialAsset.java new file mode 100644 index 0000000000..cc2398457f --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/FinancialAsset.java @@ -0,0 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +@Entity +public class FinancialAsset extends Asset { + private double price; + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Folder.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Folder.java new file mode 100755 index 0000000000..51fdd002c9 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Folder.java @@ -0,0 +1,38 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.OneToMany; + +/** + * @author Emmanuel Bernard + */ +@Entity +public class Folder extends File { + @OneToMany(mappedBy = "parent") + private Set children = new HashSet(); + + Folder() { + } + + public Folder(String name) { + super( name ); + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children = children; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/JoinedSubclassTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/JoinedSubclassTest.java new file mode 100755 index 0000000000..20bd95db1d --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/JoinedSubclassTest.java @@ -0,0 +1,257 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * @author Emmanuel Bernard + */ +@DomainModel( + annotatedClasses = { + File.class, + Folder.class, + Document.class, + SymbolicLink.class, + ProgramExecution.class, + Clothing.class, + Sweater.class, + EventInformation.class, + Alarm.class, + Client.class, + Account.class, + Company.class + } +) +@SessionFactory +public class JoinedSubclassTest { + + @Test + public void testDefault(SessionFactoryScope scope) { + File doc = new Document( "Enron Stuff To Shred", 1000 ); + Folder folder = new Folder( "Enron" ); + scope.inTransaction( + s -> { + s.persist( doc ); + s.persist( folder ); + } + ); + scope.inTransaction( + s -> { + CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder(); + CriteriaQuery criteria = criteriaBuilder.createQuery( File.class ); + criteria.from( File.class ); + List result = s.createQuery( criteria ).list(); +// List result = s.createCriteria( File.class ).list(); + assertNotNull( result ); + assertEquals( 2, result.size() ); + File f2 = result.get( 0 ); + checkClassType( f2, doc, folder ); + f2 = result.get( 1 ); + checkClassType( f2, doc, folder ); + } + ); + } + + @Test + public void testManyToOneOnAbstract(SessionFactoryScope scope) { + Folder f = new Folder(); + f.setName( "data" ); + ProgramExecution remove = new ProgramExecution(); + remove.setAction( "remove" ); + remove.setAppliesOn( f ); + + scope.inTransaction( + session -> { + session.persist( f ); + session.persist( remove ); + } + ); + + scope.inTransaction( + session -> { + ProgramExecution programExecution = session.get( ProgramExecution.class, remove.getId() ); + assertNotNull( programExecution ); + assertNotNull( programExecution.getAppliesOn().getName() ); + } + ); + } + + @Test + public void testJoinedAbstractClass(SessionFactoryScope scope) { + Sweater sw = new Sweater(); + sw.setColor( "Black" ); + sw.setSize( 2 ); + sw.setSweat( true ); + + scope.inTransaction( + session -> session.persist( sw ) + + ); + + scope.inTransaction( + session -> { + Sweater toDelete = session.get( Sweater.class, sw.getId() ); + session.delete( toDelete ); + } + ); + } + + @Test + public void testInheritance(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + String eventPK = "event1"; + EventInformation event = session.get( EventInformation.class, eventPK ); + if ( event == null ) { + event = new EventInformation(); + event.setNotificationId( eventPK ); + session.persist( event ); + } + String alarmPK = "alarm1"; + Alarm alarm = session.get( Alarm.class, alarmPK ); + if ( alarm == null ) { + alarm = new Alarm(); + alarm.setNotificationId( alarmPK ); + alarm.setEventInfo( event ); + session.persist( alarm ); + } + } + ); + } + + @Test + @TestForIssue(jiraKey = "HHH-4250") + public void testManyToOneWithJoinTable(SessionFactoryScope scope) { + //HHH-4250 : @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED) + scope.inTransaction( + session -> { + Client c1 = new Client(); + c1.setFirstname( "Firstname1" ); + c1.setName( "Name1" ); + c1.setCode( "1234" ); + c1.setStreet( "Street1" ); + c1.setCity( "City1" ); + + Account a1 = new Account(); + a1.setNumber( "1000" ); + a1.setBalance( 5000.0 ); + + a1.addClient( c1 ); + + session.persist( c1 ); + session.persist( a1 ); + + session.flush(); + session.clear(); + + c1 = session.load( Client.class, c1.getId() ); + assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 ); + + session.flush(); + session.clear(); + + a1 = session.load( Account.class, a1.getId() ); + Set clients = a1.getClients(); + assertEquals( 1, clients.size() ); + Iterator it = clients.iterator(); + c1 = it.next(); + assertEquals( "Name1", c1.getName() ); + } + ); + } + + @Test + @TestForIssue(jiraKey = "HHH-4240") + public void testSecondaryTables(SessionFactoryScope scope) { + // HHH-4240 - SecondaryTables not recognized when using JOINED inheritance + Company company = new Company(); + company.setCustomerName( "Mama" ); + company.setCustomerCode( "123" ); + company.setCompanyName( "Mama Mia Pizza" ); + company.setCompanyAddress( "Rome" ); + scope.inTransaction( + session -> + session.persist( company ) + ); + + scope.inTransaction( + session -> { + Company c = session.get( Company.class, company.getId() ); + assertEquals( "Mama", c.getCustomerName() ); + assertEquals( "123", c.getCustomerCode() ); + assertEquals( "Mama Mia Pizza", c.getCompanyName() ); + assertEquals( "Rome", c.getCompanyAddress() ); + } + ); + } + + private void checkClassType(File fruitToTest, File f, Folder a) { + if ( fruitToTest.getName().equals( f.getName() ) ) { + assertFalse( fruitToTest instanceof Folder ); + } + else if ( fruitToTest.getName().equals( a.getName() ) ) { + assertTrue( fruitToTest instanceof Folder ); + } + else { + fail( "Result does not contains the previously inserted elements" ); + } + } + + @AfterEach + public void tearDown(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + session.createQuery( "from Customer" ).list().forEach( + customer -> session.delete( customer ) + ); + + session.createQuery( "from Account" ).list().forEach( + account -> session.delete( account ) + ); + + session.createQuery( "from Client" ).list().forEach( + client -> session.delete( client ) + ); + + session.createQuery( "from ProgramExecution" ).list().forEach( + programExecution -> session.delete( programExecution ) + ); + + session.createQuery( "from Alarm" ).list().forEach( + alarm -> session.delete( alarm ) + ); + + session.createQuery( "from EventInformation" ).list().forEach( + eventInformation -> session.delete( eventInformation ) + ); + + + session.createQuery( "from File" ).list().forEach( + file -> session.delete( file ) + ); + } + ); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/LegalEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/LegalEntity.java new file mode 100644 index 0000000000..8285f635e0 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/LegalEntity.java @@ -0,0 +1,35 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +/** + * @author Sharath Reddy + * + */ +@MappedSuperclass +public class LegalEntity { + + private Long id; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Parent.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Parent.java new file mode 100644 index 0000000000..2d11947da5 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Parent.java @@ -0,0 +1,56 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +/** + * @author Emmanuel Bernard + */ +@Entity +@Table(name = "Parent") +public class Parent { + private Integer id; + private Set propertyAssets = new HashSet(); + private Set financialAssets = new HashSet(); + + @Id @GeneratedValue public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = PropertyAsset.class) + public Set getPropertyAssets() { + return this.propertyAssets; + } + + public void setPropertyAssets(Set propertyAssets) { + this.propertyAssets = propertyAssets; + } + + @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = FinancialAsset.class) + public Set getFinancialAssets() { + return this.financialAssets; + } + + public void setFinancialAssets(Set financialAssets) { + this.financialAssets = financialAssets; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Person.java new file mode 100644 index 0000000000..3529a217b0 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Person.java @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +@Table(name = "PERSON") +public class Person { + + @Id + @GeneratedValue + private int id; + + private String name; + + private String firtsname; + + public Person() { + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFirstname() { + return firtsname; + } + + public void setFirstname(String firstname) { + this.firtsname = firstname; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} + diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Pool.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Pool.java new file mode 100644 index 0000000000..523486c77d --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Pool.java @@ -0,0 +1,71 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.SecondaryTable; +import javax.persistence.SecondaryTables; + +import org.hibernate.annotations.Tables; + +/** + * @author Emmanuel Bernard + */ +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +@SecondaryTables({ + @SecondaryTable(name="POOL_ADDRESS"), + @SecondaryTable(name="POOL_ADDRESS_2") +}) +@Tables({ + @org.hibernate.annotations.Table(appliesTo="POOL_ADDRESS", optional=true), + @org.hibernate.annotations.Table(appliesTo="POOL_ADDRESS_2", optional=true, inverse = true) +}) +public class Pool { + @Id @GeneratedValue + private Integer id; + + @Embedded + private PoolAddress address; + + @Embedded + @AttributeOverride(name = "address", column = @Column(table = "POOL_ADDRESS_2")) + private PoolAddress secondaryAddress; + + public PoolAddress getAddress() { + return address; + } + + public void setAddress(PoolAddress address) { + this.address = address; + } + + public PoolAddress getSecondaryAddress() { + return secondaryAddress; + } + + public void setSecondaryAddress(PoolAddress secondaryAddress) { + this.secondaryAddress = secondaryAddress; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PoolAddress.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PoolAddress.java new file mode 100644 index 0000000000..f71be89b4d --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PoolAddress.java @@ -0,0 +1,24 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * 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.orm.test.annotations.inheritance.joined; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class PoolAddress { + @Column(table = "POOL_ADDRESS") + private String address; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/ProgramExecution.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/ProgramExecution.java new file mode 100644 index 0000000000..56f1228b01 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/ProgramExecution.java @@ -0,0 +1,54 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * @author Emmanuel Bernard + */ +@Entity +public class ProgramExecution { + @Id + @GeneratedValue + private Integer id; + private String action; + @ManyToOne(fetch = FetchType.LAZY) + private File appliesOn; + + + public File getAppliesOn() { + return appliesOn; + } + + public void setAppliesOn(File appliesOn) { + this.appliesOn = appliesOn; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PropertyAsset.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PropertyAsset.java new file mode 100644 index 0000000000..e4749fce41 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/PropertyAsset.java @@ -0,0 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +@Entity +public class PropertyAsset extends Asset { + private double price; + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Sweater.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Sweater.java new file mode 100644 index 0000000000..745ef0ca4e --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/Sweater.java @@ -0,0 +1,29 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; + +/** + * @author Emmanuel Bernard + */ +@Entity +@PrimaryKeyJoinColumn(name = "clothing_id") +public class Sweater extends Clothing { + private boolean isSweat; + + public boolean isSweat() { + return isSweat; + } + + public void setSweat(boolean sweat) { + isSweat = sweat; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SwimmingPool.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SwimmingPool.java new file mode 100644 index 0000000000..dec3a85dc3 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SwimmingPool.java @@ -0,0 +1,18 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; + +/** + * @author Emmanuel Bernard + */ +@Entity +public class SwimmingPool extends Pool { +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SymbolicLink.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SymbolicLink.java new file mode 100755 index 0000000000..727e57d04e --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/joined/SymbolicLink.java @@ -0,0 +1,36 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ + +//$Id$ +package org.hibernate.orm.test.annotations.inheritance.joined; + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + +@Entity +public class SymbolicLink extends File { + + @ManyToOne(optional = false) + File target; + + SymbolicLink() { + } + + public SymbolicLink(File target) { + this.target = target; + } + + public File getTarget() { + return target; + } + + public void setTarget(File target) { + this.target = target; + } + + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/Document.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/Document.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/Document.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/Document.java index b046e3bce6..effc14940b 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/Document.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/Document.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.mixed; +package org.hibernate.orm.test.annotations.inheritance.mixed; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/File.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/File.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/File.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/File.java index e681d4b89b..403d391fbd 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/File.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/File.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.mixed; +package org.hibernate.orm.test.annotations.inheritance.mixed; import javax.persistence.DiscriminatorColumn; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/Folder.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/Folder.java similarity index 92% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/Folder.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/Folder.java index 788cc6eac0..031b162783 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/Folder.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/Folder.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.mixed; +package org.hibernate.orm.test.annotations.inheritance.mixed; import java.util.HashSet; import java.util.Set; import javax.persistence.DiscriminatorValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SubclassTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/SubclassTest.java similarity index 71% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SubclassTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/SubclassTest.java index 5ef5139700..d898343b3a 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SubclassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/SubclassTest.java @@ -4,19 +4,17 @@ * 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.test.annotations.inheritance.mixed; +package org.hibernate.orm.test.annotations.inheritance.mixed; import java.util.List; - import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import org.junit.Test; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.exception.SQLGrammarException; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -27,27 +25,30 @@ import static org.junit.Assert.fail; /** * @author Emmanuel Bernard */ -public class SubclassTest extends BaseCoreFunctionalTestCase { +@DomainModel( + annotatedClasses = { + File.class, + Folder.class, + Document.class, + SymbolicLink.class + } +) +@SessionFactory +public class SubclassTest { + @Test - public void testDefault() { - Session s; - Transaction tx; - s = openSession(); - tx = s.beginTransaction(); + public void testDefault(SessionFactoryScope scope) { File doc = new Document( "Enron Stuff To Shred", 1000 ); Folder folder = new Folder( "Enron" ); - try { - s.persist( doc ); - s.persist( folder ); + scope.inTransaction( + session -> + { + session.persist( doc ); + session.persist( folder ); + } + ); - tx.commit(); - } - catch (SQLGrammarException e) { - System.err.println( e.getSQLException().getNextException() ); - } - s.close(); - - inTransaction( + scope.inTransaction( session -> { CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery criteria = criteriaBuilder.createQuery( File.class ); @@ -78,15 +79,4 @@ public class SubclassTest extends BaseCoreFunctionalTestCase { fail( "Result does not contains the previously inserted elements" ); } } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[]{ - File.class, - Folder.class, - Document.class, - SymbolicLink.class - }; - } - } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SymbolicLink.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/SymbolicLink.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SymbolicLink.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/SymbolicLink.java index 4553af191f..fc9fb1c159 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SymbolicLink.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/mixed/SymbolicLink.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.mixed; +package org.hibernate.orm.test.annotations.inheritance.mixed; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.JoinColumn; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Building.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Building.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Building.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Building.java index ba08a717db..a88159c24a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Building.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Building.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.Column; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.java similarity index 79% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.java index 3450a6b09c..f2a1ae1166 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/DuplicatedDiscriminatorValueTest.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.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorValue; @@ -21,31 +21,32 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.internal.SessionFactoryRegistry; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Assert; -import org.junit.Test; +import org.hibernate.testing.junit5.BaseUnitTest; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ @TestForIssue( jiraKey = "HHH-7214" ) -public class DuplicatedDiscriminatorValueTest extends BaseUnitTestCase { +public class DuplicatedDiscriminatorValueTest extends BaseUnitTest { private static final String DISCRIMINATOR_VALUE = "D"; @Test public void testDuplicatedDiscriminatorValueSameHierarchy() { try { tryBuildingSessionFactory( Building.class, Building1.class, Building2.class ); - Assert.fail( MappingException.class.getName() + " expected when two subclasses are mapped with the same discriminator value." ); + fail( MappingException.class.getName() + " expected when two subclasses are mapped with the same discriminator value." ); } catch ( MappingException e ) { final String errorMsg = e.getCause().getMessage(); // Check if error message contains descriptive information. - Assert.assertTrue( errorMsg.contains( Building1.class.getName() ) ); - Assert.assertTrue( errorMsg.contains( Building2.class.getName() ) ); - Assert.assertTrue( errorMsg.contains( "discriminator value '" + DISCRIMINATOR_VALUE + "'." ) ); + assertTrue( errorMsg.contains( Building1.class.getName() ) ); + assertTrue( errorMsg.contains( Building2.class.getName() ) ); + assertTrue( errorMsg.contains( "discriminator value '" + DISCRIMINATOR_VALUE + "'." ) ); } assertFalse( SessionFactoryRegistry.INSTANCE.hasRegistrations() ); @@ -57,6 +58,7 @@ public class DuplicatedDiscriminatorValueTest extends BaseUnitTestCase { } private void tryBuildingSessionFactory(Class... annotatedClasses) { + SessionFactoryRegistry.INSTANCE.clearRegistrations(); final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build(); try { final MetadataSources metadataSources = new MetadataSources( serviceRegistry ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Funk.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Funk.java similarity index 89% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Funk.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Funk.java index ff5739859f..129b21e911 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Funk.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Funk.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/House.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/House.java similarity index 86% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/House.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/House.java index 6e5aa1a167..0c6d18db68 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/House.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/House.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Music.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Music.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Music.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Music.java index 6ba12a5f0c..83e2e4c69f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Music.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Music.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.Column; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorType; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Noise.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Noise.java similarity index 86% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Noise.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Noise.java index 1541c737b6..7abe2322e1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Noise.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Noise.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/PaperTrash.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/PaperTrash.java similarity index 84% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/PaperTrash.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/PaperTrash.java index 3c7a37fb35..c9d6b8f110 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/PaperTrash.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/PaperTrash.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.Entity; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Rock.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Rock.java similarity index 86% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Rock.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Rock.java index f0663f28a3..03c67e0be3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Rock.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Rock.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Trash.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Trash.java similarity index 90% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Trash.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Trash.java index 5c247a8cce..a5b02e624b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/singletable/Trash.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/singletable/Trash.java @@ -6,7 +6,7 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.singletable; +package org.hibernate.orm.test.annotations.inheritance.singletable; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorType; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/Document.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/Document.java similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/Document.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/Document.java index 6fb0d407bf..90fb33513d 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/Document.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/Document.java @@ -6,7 +6,8 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.union; +package org.hibernate.orm.test.annotations.inheritance.union; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/File.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/File.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/File.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/File.java index e8aa16ef0b..d46244d318 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/File.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/File.java @@ -6,7 +6,8 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.union; +package org.hibernate.orm.test.annotations.inheritance.union; + import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Inheritance; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/Folder.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/Folder.java similarity index 92% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/Folder.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/Folder.java index 3cf18fbbe4..4569bf3b0a 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/Folder.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/Folder.java @@ -6,7 +6,8 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.union; +package org.hibernate.orm.test.annotations.inheritance.union; + import java.util.HashSet; import java.util.Set; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SubclassTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/SubclassTest.java similarity index 67% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SubclassTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/SubclassTest.java index 6b7f8b692e..20a0cea710 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SubclassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/SubclassTest.java @@ -4,42 +4,50 @@ * 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.test.annotations.inheritance.union; +package org.hibernate.orm.test.annotations.inheritance.union; import java.util.List; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import org.junit.Test; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Emmanuel Bernard */ -public class SubclassTest extends BaseCoreFunctionalTestCase { +@DomainModel( + annotatedClasses = { + File.class, + Folder.class, + Document.class, + SymbolicLink.class + } +) +@SessionFactory +public class SubclassTest { @Test - public void testDefault() { + public void testDefault(SessionFactoryScope scope) { File doc = new Document( "Enron Stuff To Shred", 1000 ); Folder folder = new Folder( "Enron" ); - inTransaction( + scope.inTransaction( s -> { s.persist( doc ); s.persist( folder ); } ); - inTransaction( + scope.inTransaction( s -> { CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder(); CriteriaQuery criteria = criteriaBuilder.createQuery( File.class ); @@ -68,14 +76,4 @@ public class SubclassTest extends BaseCoreFunctionalTestCase { } } - @Override - protected Class[] getAnnotatedClasses() { - return new Class[]{ - File.class, - Folder.class, - Document.class, - SymbolicLink.class - }; - } - } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SymbolicLink.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/SymbolicLink.java similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SymbolicLink.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/SymbolicLink.java index 9717e56569..1ad6cb3fbd 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SymbolicLink.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/inheritance/union/SymbolicLink.java @@ -6,7 +6,8 @@ */ //$Id$ -package org.hibernate.test.annotations.inheritance.union; +package org.hibernate.orm.test.annotations.inheritance.union; + import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.Table; diff --git a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Doctor.java similarity index 89% rename from hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Doctor.java index e32537371b..1219c32a34 100644 --- a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Doctor.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.subclassProxyInterface; +package org.hibernate.orm.test.subclassProxyInterface; /** diff --git a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/IDoctor.java similarity index 85% rename from hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/IDoctor.java index 7da328a576..7ebfffd103 100644 --- a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/IDoctor.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.subclassProxyInterface; +package org.hibernate.orm.test.subclassProxyInterface; /** diff --git a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Person.hbm.xml similarity index 90% rename from hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Person.hbm.xml index c316895783..abb85d7ded 100644 --- a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Person.hbm.xml @@ -9,7 +9,7 @@ "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> - + diff --git a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Person.java similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Person.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Person.java index 1feef652b2..e8dfbb3974 100644 --- a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/Person.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.subclassProxyInterface; +package org.hibernate.orm.test.subclassProxyInterface; /** diff --git a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java similarity index 81% rename from hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java index 7307370a5a..a64cba25e8 100644 --- a/hibernate-core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java @@ -4,21 +4,20 @@ * 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.subclassProxyInterface; - -import org.junit.Test; +package org.hibernate.orm.test.subclassProxyInterface; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.dialect.H2Dialect; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.ServiceRegistryBuilder; -import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.junit5.BaseUnitTest; +import org.junit.jupiter.api.Test; /** * @author Steve Ebersole */ -public class SubclassProxyInterfaceTest extends BaseUnitTestCase { +public class SubclassProxyInterfaceTest extends BaseUnitTest { @Test public void testSubclassProxyInterfaces() { final Configuration cfg = new Configuration() diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java deleted file mode 100644 index 34c58bcf7e..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * 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.test.annotations.genericsinheritance; - -import org.junit.Test; - -import org.hibernate.Session; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -/** - * @author Emmanuel Bernard - */ -public class GenericsInheritanceTest extends BaseCoreFunctionalTestCase { - @Test - public void testMapping() throws Exception { - Session s = openSession(); - s.close(); - //mapping is tested - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { - ChildHierarchy1.class, - ParentHierarchy1.class, - ChildHierarchy22.class, - ParentHierarchy22.class - }; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/SubclassTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/SubclassTest.java index d739ecc000..75edfcacf2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/SubclassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/SubclassTest.java @@ -19,10 +19,10 @@ import org.hibernate.query.Query; import org.hibernate.test.annotations.A320; import org.hibernate.test.annotations.A320b; import org.hibernate.test.annotations.Plane; -import org.hibernate.test.annotations.inheritance.singletable.Funk; -import org.hibernate.test.annotations.inheritance.singletable.Music; -import org.hibernate.test.annotations.inheritance.singletable.Noise; -import org.hibernate.test.annotations.inheritance.singletable.Rock; +import org.hibernate.orm.test.annotations.inheritance.singletable.Funk; +import org.hibernate.orm.test.annotations.inheritance.singletable.Music; +import org.hibernate.orm.test.annotations.inheritance.singletable.Noise; +import org.hibernate.orm.test.annotations.inheritance.singletable.Rock; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Account.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Account.java index 37899d0365..4bf361a913 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Account.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Account.java @@ -4,8 +4,8 @@ * 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.test.annotations.inheritance.joined; + import java.io.Serializable; import java.util.HashSet; import java.util.Set; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Alarm.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Alarm.java index 34944e6975..ccd060c7c7 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Alarm.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Alarm.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.JoinColumn; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Asset.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Asset.java index b165965e7d..99550ea095 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Asset.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Asset.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Client.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Client.java index 2f5b594af7..984376d07f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Client.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Client.java @@ -4,8 +4,8 @@ * 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.test.annotations.inheritance.joined; + import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -30,8 +30,6 @@ public class Client extends Person implements Serializable { joinColumns = {@JoinColumn(name = "FK_CLIENT", referencedColumnName = "ID")}, inverseJoinColumns = {@JoinColumn(name = "FK_ACCOUNT", referencedColumnName = "ID")}) private Account account; - - public Account getAccount() { return account; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Clothing.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Clothing.java index 027718728a..a2e974b7a1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Clothing.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Clothing.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java index b357437ae4..3247cf91a8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Company.java @@ -5,6 +5,7 @@ * See the lgpl.txt file in the root directory or . */ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.SecondaryTable; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java index 83d298083c..3058227e90 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Customer.java @@ -4,8 +4,8 @@ * 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.test.annotations.inheritance.joined; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Inheritance; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java index 026d43ffc2..0ab8709ca0 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Column; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/EventInformation.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/EventInformation.java index 60ddabb48a..5d73fa3744 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/EventInformation.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/EventInformation.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorType; import javax.persistence.DiscriminatorValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/File.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/File.java index 3ccc3d4664..fe202a9409 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/File.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/File.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java index b29e6c90b7..f2cfb4e47f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Folder.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Folder.java index c1eb4d064a..6b6cb55147 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Folder.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Folder.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import java.util.HashSet; import java.util.Set; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java index 11bf2438b5..2b815e239f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java @@ -6,100 +6,121 @@ */ package org.hibernate.test.annotations.inheritance.joined; -import org.junit.Test; - import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * @author Emmanuel Bernard */ -public class JoinedSubclassAndSecondaryTable extends BaseCoreFunctionalTestCase { +@DomainModel( + annotatedClasses = { + Pool.class, + SwimmingPool.class + } +) +@SessionFactory +public class JoinedSubclassAndSecondaryTable { - @Test - public void testSecondaryTableAndJoined() { - Session s = openSession(); - Transaction tx = s.beginTransaction(); - SwimmingPool sp = new SwimmingPool(); - s.persist( sp ); - s.flush(); - s.clear(); - - long rowCount = getTableRowCount( s, "POOL_ADDRESS" ); - assertEquals( - "The address table is marked as optional. For null values no database row should be created", - 0, - rowCount + @AfterEach + public void tearDown(SessionFactoryScope scope) { + scope.inTransaction( + sesison -> + sesison.createQuery( "from Pool" ).list().forEach( + pool -> sesison.delete( pool ) + ) ); - - SwimmingPool sp2 = (SwimmingPool) s.get( SwimmingPool.class, sp.getId() ); - assertNull( sp.getAddress() ); - - PoolAddress address = new PoolAddress(); - address.setAddress( "Park Avenue" ); - sp2.setAddress( address ); - - s.flush(); - s.clear(); - - sp2 = (SwimmingPool) s.get( SwimmingPool.class, sp.getId() ); - rowCount = getTableRowCount( s, "POOL_ADDRESS" ); - assertEquals( - "Now we should have a row in the pool address table ", - 1, - rowCount - ); - assertNotNull( sp2.getAddress() ); - assertEquals( sp2.getAddress().getAddress(), "Park Avenue" ); - - tx.rollback(); - s.close(); } @Test - public void testSecondaryTableAndJoinedInverse() throws Exception { - Session s = openSession(); - Transaction tx = s.beginTransaction(); - SwimmingPool sp = new SwimmingPool(); - s.persist( sp ); - s.flush(); - s.clear(); + public void testSecondaryTableAndJoined(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + SwimmingPool sp = new SwimmingPool(); + session.persist( sp ); + session.flush(); + session.clear(); - long rowCount = getTableRowCount( s, "POOL_ADDRESS_2" ); - assertEquals( - "The address table is marked as optional. For null values no database row should be created", - 0, - rowCount + long rowCount = getTableRowCount( session, "POOL_ADDRESS" ); + assertEquals( + + 0, + rowCount, + "The address table is marked as optional. For null values no database row should be created" + ); + + SwimmingPool sp2 = session.get( SwimmingPool.class, sp.getId() ); + assertNull( sp.getAddress() ); + + PoolAddress address = new PoolAddress(); + address.setAddress( "Park Avenue" ); + sp2.setAddress( address ); + + session.flush(); + session.clear(); + + sp2 = session.get( SwimmingPool.class, sp.getId() ); + rowCount = getTableRowCount( session, "POOL_ADDRESS" ); + assertEquals( + + 1, + rowCount, + "Now we should have a row in the pool address table " + + ); + assertNotNull( sp2.getAddress() ); + assertEquals( sp2.getAddress().getAddress(), "Park Avenue" ); + } ); + } - SwimmingPool sp2 = (SwimmingPool) s.get( SwimmingPool.class, sp.getId() ); - assertNull( sp.getSecondaryAddress() ); + @Test + public void testSecondaryTableAndJoinedInverse(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + SwimmingPool sp = new SwimmingPool(); + session.persist( sp ); + session.flush(); + session.clear(); - PoolAddress address = new PoolAddress(); - address.setAddress( "Park Avenue" ); - sp2.setSecondaryAddress( address ); + long rowCount = getTableRowCount( session, "POOL_ADDRESS_2" ); + assertEquals( + 0, + rowCount, + "The address table is marked as optional. For null values no database row should be created" + ); - s.flush(); - s.clear(); + SwimmingPool sp2 = session.get( SwimmingPool.class, sp.getId() ); + assertNull( sp.getSecondaryAddress() ); - sp2 = (SwimmingPool) s.get( SwimmingPool.class, sp.getId() ); - rowCount = getTableRowCount( s, "POOL_ADDRESS_2" ); - assertEquals( - "Now we should have a row in the pool address table ", - 0, - rowCount + PoolAddress address = new PoolAddress(); + address.setAddress( "Park Avenue" ); + sp2.setSecondaryAddress( address ); + + session.flush(); + session.clear(); + + sp2 = session.get( SwimmingPool.class, sp.getId() ); + rowCount = getTableRowCount( session, "POOL_ADDRESS_2" ); + assertEquals( + + 0, + rowCount, + "Now we should have a row in the pool address table " + ); + assertNull( sp2.getSecondaryAddress() ); + } ); - assertNull( sp2.getSecondaryAddress() ); - - tx.rollback(); - s.close(); } private long getTableRowCount(Session s, String tableName) { @@ -108,11 +129,6 @@ public class JoinedSubclassAndSecondaryTable extends BaseCoreFunctionalTestCase // H2 returns Types.BIGINT, which is mapped to BigInteger; Object retVal = s.createNativeQuery( "select count(*) from " + tableName ).uniqueResult(); assertTrue( Number.class.isInstance( retVal ) ); - return ( ( Number ) retVal ).longValue(); - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { Pool.class, SwimmingPool.class }; + return ( (Number) retVal ).longValue(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java deleted file mode 100755 index bdfc0be748..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * 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.test.annotations.inheritance.joined; - -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; - -import org.hibernate.Session; -import org.hibernate.Transaction; - -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * @author Emmanuel Bernard - */ -public class JoinedSubclassTest extends BaseCoreFunctionalTestCase { - @Test - public void testDefault() { - File doc = new Document( "Enron Stuff To Shred", 1000 ); - Folder folder = new Folder( "Enron" ); - inTransaction( - s -> { - s.persist( doc ); - s.persist( folder ); - } - ); - inTransaction( - s -> { - CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder(); - CriteriaQuery criteria = criteriaBuilder.createQuery( File.class ); - criteria.from( File.class ); - List result = s.createQuery( criteria ).list(); -// List result = s.createCriteria( File.class ).list(); - assertNotNull( result ); - assertEquals( 2, result.size() ); - File f2 = result.get( 0 ); - checkClassType( f2, doc, folder ); - f2 = result.get( 1 ); - checkClassType( f2, doc, folder ); - s.delete( result.get( 0 ) ); - s.delete( result.get( 1 ) ); - } - ); - } - - @Test - public void testManyToOneOnAbstract() throws Exception { - Folder f = new Folder(); - f.setName( "data" ); - ProgramExecution remove = new ProgramExecution(); - remove.setAction( "remove" ); - remove.setAppliesOn( f ); - - try(Session s = openSession()) { - Transaction tx = s.beginTransaction(); - try { - s.persist( f ); - s.persist( remove ); - tx.commit(); - s.clear(); - tx = s.beginTransaction(); - remove = s.get( ProgramExecution.class, remove.getId() ); - assertNotNull( remove ); - assertNotNull( remove.getAppliesOn().getName() ); - s.delete( remove ); - s.delete( remove.getAppliesOn() ); - - tx.commit(); - } - catch (Exception e) { - if ( s.getTransaction().isActive() ) { - s.getTransaction().rollback(); - } - throw e; - } - } - } - - private void checkClassType(File fruitToTest, File f, Folder a) { - if ( fruitToTest.getName().equals( f.getName() ) ) { - assertFalse( fruitToTest instanceof Folder ); - } - else if ( fruitToTest.getName().equals( a.getName() ) ) { - assertTrue( fruitToTest instanceof Folder ); - } - else { - fail( "Result does not contains the previously inserted elements" ); - } - } - - @Test - public void testJoinedAbstractClass() { - Session s; - s = openSession(); - s.getTransaction().begin(); - Sweater sw = new Sweater(); - sw.setColor( "Black" ); - sw.setSize( 2 ); - sw.setSweat( true ); - s.persist( sw ); - s.getTransaction().commit(); - s.clear(); - - s = openSession(); - s.getTransaction().begin(); - sw = s.get( Sweater.class, sw.getId() ); - s.delete( sw ); - s.getTransaction().commit(); - s.close(); - } - - @Test - public void testInheritance() { - Session session = openSession(); - Transaction transaction = session.beginTransaction(); - String eventPK = "event1"; - EventInformation event = session.get( EventInformation.class, eventPK ); - if ( event == null ) { - event = new EventInformation(); - event.setNotificationId( eventPK ); - session.persist( event ); - } - String alarmPK = "alarm1"; - Alarm alarm = (Alarm) session.get( Alarm.class, alarmPK ); - if ( alarm == null ) { - alarm = new Alarm(); - alarm.setNotificationId( alarmPK ); - alarm.setEventInfo( event ); - session.persist( alarm ); - } - transaction.commit(); - session.close(); - } - - @Test - @TestForIssue( jiraKey = "HHH-4250" ) - public void testManyToOneWithJoinTable() { - //HHH-4250 : @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED) - Session s = openSession(); - Transaction tx = s.beginTransaction(); - - Client c1 = new Client(); - c1.setFirstname("Firstname1"); - c1.setName("Name1"); - c1.setCode("1234"); - c1.setStreet("Street1"); - c1.setCity("City1"); - - Account a1 = new Account(); - a1.setNumber("1000"); - a1.setBalance(5000.0); - - a1.addClient(c1); - - s.persist(c1); - s.persist(a1); - - s.flush(); - s.clear(); - - c1 = s.load(Client.class, c1.getId()); - assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 ); - - s.flush(); - s.clear(); - - a1 = s.load(Account.class,a1.getId()); - Set clients = a1.getClients(); - assertEquals(1, clients.size()); - Iterator it = clients.iterator(); - c1 = it.next(); - assertEquals("Name1", c1.getName()); - - tx.rollback(); - s.close(); - } - - @Test - @TestForIssue( jiraKey = "HHH-4240" ) - public void testSecondaryTables() { - // HHH-4240 - SecondaryTables not recognized when using JOINED inheritance - Session s = openSession(); - s.getTransaction().begin(); - - Company company = new Company(); - company.setCustomerName("Mama"); - company.setCustomerCode("123"); - company.setCompanyName("Mama Mia Pizza"); - company.setCompanyAddress("Rome"); - - s.persist( company ); - s.getTransaction().commit(); - s.clear(); - - s = openSession(); - s.getTransaction().begin(); - company = (Company) s.get( Company.class, company.getId()); - assertEquals("Mama", company.getCustomerName()); - assertEquals("123", company.getCustomerCode()); - assertEquals("Mama Mia Pizza", company.getCompanyName()); - assertEquals("Rome", company.getCompanyAddress()); - - s.delete( company ); - s.getTransaction().commit(); - s.close(); - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[]{ - File.class, - Folder.class, - Document.class, - SymbolicLink.class, - ProgramExecution.class, - Clothing.class, - Sweater.class, - EventInformation.class, - Alarm.class, - Client.class, - Account.class, - Company.class - }; - } - -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java index bc23f856f8..90dbfad6cd 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/LegalEntity.java @@ -4,8 +4,8 @@ * 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.test.annotations.inheritance.joined; + import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Parent.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Parent.java index 6ad3987063..9b0cca34c1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Parent.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Parent.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Person.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Person.java index d1abc1c357..a90e15ff5d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Person.java @@ -4,8 +4,8 @@ * 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.test.annotations.inheritance.joined; + import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Pool.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Pool.java index d280edc2a4..d22efd0813 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Pool.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Pool.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import org.hibernate.annotations.Tables; import javax.persistence.AttributeOverride; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/ProgramExecution.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/ProgramExecution.java index f7c46b0063..bdae51f5dd 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/ProgramExecution.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/ProgramExecution.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java index 05dc418426..ecf90b8f3b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Sweater.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Sweater.java index 823aaa7216..427936ab05 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Sweater.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Sweater.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; import javax.persistence.PrimaryKeyJoinColumn; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java index 2a4db2ebb9..1af7a8c1f8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SymbolicLink.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SymbolicLink.java index 53c9fb8b0f..28f53ecf1f 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SymbolicLink.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/SymbolicLink.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.test.annotations.inheritance.joined; + import javax.persistence.Entity; import javax.persistence.ManyToOne;