diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagContainsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagContainsTest.java index c0572cc8b2..b18136c364 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagContainsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagContainsTest.java @@ -14,6 +14,7 @@ import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import org.hibernate.annotations.processing.Exclude; import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.SessionFactory; @@ -34,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; } ) @SessionFactory +@Exclude public class PersistentBagContainsTest { /** diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/event/entity/MergeListPreAndPostPersistTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/event/entity/MergeListPreAndPostPersistTest.java index 25457e47b3..ec02ab8e10 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/event/entity/MergeListPreAndPostPersistTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/event/entity/MergeListPreAndPostPersistTest.java @@ -13,6 +13,7 @@ import jakarta.persistence.Id; import jakarta.persistence.OneToMany; import org.hibernate.Session; +import org.hibernate.annotations.processing.Exclude; import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.event.spi.EventType; import org.hibernate.event.spi.PostInsertEvent; @@ -31,6 +32,7 @@ import static org.junit.Assert.assertEquals; * @author Gail Badner */ @JiraKey( value = "HHH-9979") +@Exclude public class MergeListPreAndPostPersistTest extends BaseCoreFunctionalTestCase { protected Class[] getAnnotatedClasses() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/QuotedIdentifierTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/QuotedIdentifierTest.java index ed50fade6c..79b2d59fa6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/QuotedIdentifierTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/QuotedIdentifierTest.java @@ -6,6 +6,7 @@ package org.hibernate.orm.test.hql; import java.util.List; +import org.hibernate.annotations.processing.Exclude; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.After; import org.junit.Before; @@ -24,6 +25,7 @@ import static org.junit.Assert.assertEquals; /** * @author Christian Beikov */ +@Exclude public class QuotedIdentifierTest extends BaseCoreFunctionalTestCase { private Person person; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java index 8b9f3bcf74..88bd7d20d9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java @@ -14,6 +14,7 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; +import org.hibernate.annotations.processing.Exclude; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; @@ -36,6 +37,7 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @JiraKey(value = "HHH-13788") +@Exclude public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest { private File updateOutputFile; diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/Dummy.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/Dummy.java new file mode 100644 index 0000000000..20cf26df95 --- /dev/null +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/Dummy.java @@ -0,0 +1,82 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.processor.test.data.innerclass; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.NamedQuery; + +public class Dummy { + @Entity(name = "Inner") + @NamedQuery(name = "allInner", query = "from Inner") + public static class Inner extends Persona { + @Id + Integer id; + + String name; + + public Integer getId() { + return id; + } + + @Override + public void setId(Integer id) { + this.id = id; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } + } + + @Embeddable + public static class DummyEmbeddable { + private String name; + private int value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + } + + @MappedSuperclass + public abstract static class Persona { + private String city; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public abstract void setId(Integer id); + + public abstract String getName(); + + public abstract void setName(String name); + } +} diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/InnerClassTest.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/InnerClassTest.java new file mode 100644 index 0000000000..70bcec8736 --- /dev/null +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/InnerClassTest.java @@ -0,0 +1,86 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.processor.test.data.innerclass; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQuery; +import org.hibernate.processor.test.data.innerclass.InnerClassTest.One.Two; +import org.hibernate.processor.test.util.CompilationTest; +import org.hibernate.processor.test.util.WithClasses; +import org.junit.Test; + +import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor; +import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor; +import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString; +import static org.junit.Assert.assertEquals; + +public class InnerClassTest extends CompilationTest { + + @WithClasses({Person.class, Dummy.class, Inner.class, Two.class}) + @Test + public void test() { + System.out.println( getMetaModelSourceAsString( InnerClassTest.class ) ); + System.out.println( getMetaModelSourceAsString( Dummy.class ) ); + System.out.println( getMetaModelSourceAsString( Person.class ) ); + System.out.println( getMetaModelSourceAsString( InnerClassTest.class, true ) ); + System.out.println( getMetaModelSourceAsString( Dummy.class, true ) ); + System.out.println( getMetaModelSourceAsString( Person.class, true ) ); + assertEquals( + getMetaModelSourceAsString( Inner.class ), + getMetaModelSourceAsString( Two.class ) + ); + assertEquals( + getMetaModelSourceAsString( Inner.class, true ), + getMetaModelSourceAsString( Two.class, true ) + ); + assertMetamodelClassGeneratedFor( Inner.class ); + assertMetamodelClassGeneratedFor( Inner.class, true ); + assertMetamodelClassGeneratedFor( Two.class ); + assertMetamodelClassGeneratedFor( Two.class, true ); + assertMetamodelClassGeneratedFor( Dummy.Inner.class ); + assertMetamodelClassGeneratedFor( Dummy.Inner.class, true ); + assertMetamodelClassGeneratedFor( Person.class ); + assertMetamodelClassGeneratedFor( Person.class, true ); + assertMetamodelClassGeneratedFor( Person.PersonId.class ); + assertNoMetamodelClassGeneratedFor( Dummy.class ); + assertMetamodelClassGeneratedFor( Dummy.DummyEmbeddable.class ); + /*assertNoMetamodelClassGeneratedFor( Dummy.class );*/ + } + + @Entity(name = "Inner") + @NamedQuery(name = "allInner", query = "from Inner") + public static class Inner { + @Id + Integer id; + + String address; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + } + + static class One { + @Entity + static class Two { + @Id + Integer id; + String value; + } + } +} diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/Person.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/Person.java new file mode 100644 index 0000000000..6f0ec32e4b --- /dev/null +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/innerclass/Person.java @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.processor.test.data.innerclass; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; + +/** + * @author Hardy Ferentschik + */ +@Entity +public class Person { + @EmbeddedId + private PersonId id; + + private String address; + + @Embeddable + public static class PersonId { + private String name; + private String snn; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSnn() { + return snn; + } + + public void setSnn(String snn) { + this.snn = snn; + } + } + + +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/Dummy.java b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/Dummy.java new file mode 100644 index 0000000000..6e17a018c7 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/Dummy.java @@ -0,0 +1,82 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.processor.test.innerclass; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.NamedQuery; + +public class Dummy { + @Entity(name = "Inner") + @NamedQuery(name = "allInner", query = "from Inner") + public static class Inner extends Persona { + @Id + Integer id; + + String name; + + public Integer getId() { + return id; + } + + @Override + public void setId(Integer id) { + this.id = id; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } + } + + @Embeddable + public static class DummyEmbeddable { + private String name; + private int value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + } + + @MappedSuperclass + public abstract static class Persona { + private String city; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public abstract void setId(Integer id); + + public abstract String getName(); + + public abstract void setName(String name); + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/InnerClassTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/InnerClassTest.java new file mode 100644 index 0000000000..cd7cea71c8 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/InnerClassTest.java @@ -0,0 +1,75 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.processor.test.innerclass; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQuery; +import org.hibernate.processor.test.innerclass.InnerClassTest.One.Two; +import org.hibernate.processor.test.util.CompilationTest; +import org.hibernate.processor.test.util.WithClasses; +import org.junit.Test; + +import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor; +import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor; +import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString; +import static org.junit.Assert.assertEquals; + +public class InnerClassTest extends CompilationTest { + + @WithClasses({Person.class, Dummy.class, Inner.class, Two.class}) + @Test + public void test() { + System.out.println( getMetaModelSourceAsString( InnerClassTest.class ) ); + System.out.println( getMetaModelSourceAsString( Dummy.class ) ); + System.out.println( getMetaModelSourceAsString( Person.class ) ); + assertEquals( + getMetaModelSourceAsString( Inner.class ), + getMetaModelSourceAsString( Two.class ) + ); + assertMetamodelClassGeneratedFor( Inner.class ); + assertMetamodelClassGeneratedFor( Two.class ); + assertMetamodelClassGeneratedFor( Dummy.Inner.class ); + assertMetamodelClassGeneratedFor( Person.class ); + assertMetamodelClassGeneratedFor( Person.PersonId.class ); + assertNoMetamodelClassGeneratedFor( Dummy.class ); + assertMetamodelClassGeneratedFor( Dummy.DummyEmbeddable.class ); + System.out.println( getMetaModelSourceAsString( Dummy.DummyEmbeddable.class ) ); + } + + @Entity(name = "Inner") + @NamedQuery(name = "allInner", query = "from Inner") + public static class Inner { + @Id + Integer id; + + String address; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + } + + static class One { + @Entity + static class Two { + @Id + Integer id; + String value; + } + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/Person.java b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/Person.java new file mode 100644 index 0000000000..fc8c2fbbbe --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/innerclass/Person.java @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.processor.test.innerclass; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; + +/** + * @author Hardy Ferentschik + */ +@Entity +public class Person { + @EmbeddedId + private PersonId id; + + private String address; + + @Embeddable + public static class PersonId { + private String name; + private String snn; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSnn() { + return snn; + } + + public void setSnn(String snn) { + this.snn = snn; + } + } + + +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/separatecompilationunits/SeparateCompilationUnitsTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/separatecompilationunits/SeparateCompilationUnitsTest.java index 50645f771b..6324d68d07 100644 --- a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/separatecompilationunits/SeparateCompilationUnitsTest.java +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/separatecompilationunits/SeparateCompilationUnitsTest.java @@ -28,7 +28,12 @@ public class SeparateCompilationUnitsTest extends CompilationTest { String entityMetaModel = getMetaModelSourceAsString( Entity.class ); assertTrue( entityMetaModel.contains( - "extends org.hibernate.processor.test.separatecompilationunits.superclass.MappedSuperclass" + "import org.hibernate.processor.test.separatecompilationunits.superclass.MappedSuperclass_;" + ) + ); + assertTrue( + entityMetaModel.contains( + "extends MappedSuperclass_" ) ); }