HHH-17661 add test for issue
This commit is contained in:
parent
9ba93b7060
commit
24db2b04cc
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -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 ) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<T extends Tree<T, TR>, TR extends TreeRelation<T>> extends Entity {
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
private T parent;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "parent")
|
||||||
|
private Set<TR> childRelation = new HashSet<>();
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "child", cascade = {CascadeType.ALL}, orphanRemoval = true)
|
||||||
|
private Set<TR> parentRelation = new HashSet<>();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.hibernate.jpamodelgen.test.hhh17661;
|
||||||
|
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.MappedSuperclass;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public abstract class TreeRelation<T extends Tree<T, ? extends TreeRelation<T>>> extends Entity {
|
||||||
|
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
private T parent;
|
||||||
|
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
private T child;
|
||||||
|
}
|
Loading…
Reference in New Issue