HHH-14724 Add test for intersection types

This commit is contained in:
Thomas Heigl 2021-07-29 11:18:56 +02:00 committed by Christian Beikov
parent e868e61cec
commit 0fdf431715
3 changed files with 53 additions and 2 deletions

View File

@ -76,14 +76,21 @@ public class CollectionAsBasicTypeTest extends CompilationTest {
@TestForIssue(jiraKey = "HHH-12338")
@WithClasses({PhoneBook.class})
public void testMapType() throws ClassNotFoundException, NoSuchFieldException {
assertMetamodelClassGeneratedFor(PhoneBook.class);
assertMetamodelClassGeneratedFor( PhoneBook.class );
assertAttributeTypeInMetaModelFor(
PhoneBook.class,
"phones",
PhoneBook.class.getDeclaredField("phones").getGenericType(),
PhoneBook.class.getDeclaredField( "phones" ).getGenericType(),
"Wrong meta model type"
);
}
@Test
@TestForIssue(jiraKey = "HHH-14724")
@WithClasses({ Like.class, ConcreteLike.class })
public void testIntersectionType() {
assertMetamodelClassGeneratedFor( ConcreteLike.class );
}
}

View File

@ -0,0 +1,15 @@
package org.hibernate.jpamodelgen.test.collectionbasictype;
import javax.persistence.Entity;
@Entity(name = "ConcreteLike")
public class ConcreteLike extends Like<ConcreteLike.Target> {
@Override
public Reference<Target> getObject() {
return new Reference<>();
}
public static class Target implements Like.I1, Like.I2 {
}
}

View File

@ -0,0 +1,29 @@
package org.hibernate.jpamodelgen.test.collectionbasictype;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
/**
* @author Thomas Heigl
*/
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Like<T extends Like.I1 & Like.I2> {
@Id
private Long id;
public abstract Reference<T> getObject();
interface I1 {
}
interface I2 {
}
public static class Reference<T> {
}
}