diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/Entity.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/Entity.java new file mode 100644 index 0000000000..3627d15b13 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/Entity.java @@ -0,0 +1,14 @@ +package org.hibernate.jpamodelgen.test.hhh17661; + +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; + +import java.io.Serializable; + +@MappedSuperclass +public abstract class Entity implements Serializable { + + @Id + private Long id; + +} \ No newline at end of file diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/HHH17661Test.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/HHH17661Test.java new file mode 100644 index 0000000000..30655f88a4 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/HHH17661Test.java @@ -0,0 +1,20 @@ +package org.hibernate.jpamodelgen.test.hhh17661; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import org.hibernate.jpamodelgen.test.util.TestForIssue; +import org.hibernate.jpamodelgen.test.util.TestUtil; +import org.hibernate.jpamodelgen.test.util.WithClasses; +import org.junit.Test; + +@TestForIssue(jiraKey = " HHH-17661") +public class HHH17661Test extends CompilationTest { + + @Test + @WithClasses({ Entity.class, Tree.class, TreeRelation.class }) + @TestForIssue(jiraKey = " HHH-17661") + public void test() { + System.out.println( TestUtil.getMetaModelSourceAsString( Entity.class ) ); + System.out.println( TestUtil.getMetaModelSourceAsString( Tree.class ) ); + System.out.println( TestUtil.getMetaModelSourceAsString( TreeRelation.class ) ); + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/Tree.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/Tree.java new file mode 100644 index 0000000000..e3e2110f48 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/Tree.java @@ -0,0 +1,23 @@ +package org.hibernate.jpamodelgen.test.hhh17661; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.OneToMany; + +import java.util.HashSet; +import java.util.Set; + +@MappedSuperclass +public abstract class Tree, TR extends TreeRelation> extends Entity { + + @ManyToOne(fetch = FetchType.LAZY) + private T parent; + + @OneToMany(mappedBy = "parent") + private Set childRelation = new HashSet<>(); + + @OneToMany(mappedBy = "child", cascade = {CascadeType.ALL}, orphanRemoval = true) + private Set parentRelation = new HashSet<>(); +} \ No newline at end of file diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/TreeRelation.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/TreeRelation.java new file mode 100644 index 0000000000..4ec707ef17 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/hhh17661/TreeRelation.java @@ -0,0 +1,14 @@ +package org.hibernate.jpamodelgen.test.hhh17661; + +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; + +@MappedSuperclass +public abstract class TreeRelation>> extends Entity { + + @ManyToOne(optional = false) + private T parent; + + @ManyToOne(optional = false) + private T child; +} \ No newline at end of file