Skip to content

Commit 0fdf431

Browse files
theiglbeikov
authored andcommitted
HHH-14724 Add test for intersection types
1 parent e868e61 commit 0fdf431

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/collectionbasictype/CollectionAsBasicTypeTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,21 @@ public void testListTypeWithImport() throws ClassNotFoundException, NoSuchFieldE
7676
@TestForIssue(jiraKey = "HHH-12338")
7777
@WithClasses({PhoneBook.class})
7878
public void testMapType() throws ClassNotFoundException, NoSuchFieldException {
79-
assertMetamodelClassGeneratedFor(PhoneBook.class);
79+
assertMetamodelClassGeneratedFor( PhoneBook.class );
8080

8181
assertAttributeTypeInMetaModelFor(
8282
PhoneBook.class,
8383
"phones",
84-
PhoneBook.class.getDeclaredField("phones").getGenericType(),
84+
PhoneBook.class.getDeclaredField( "phones" ).getGenericType(),
8585
"Wrong meta model type"
8686
);
8787

8888
}
89+
90+
@Test
91+
@TestForIssue(jiraKey = "HHH-14724")
92+
@WithClasses({ Like.class, ConcreteLike.class })
93+
public void testIntersectionType() {
94+
assertMetamodelClassGeneratedFor( ConcreteLike.class );
95+
}
8996
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.hibernate.jpamodelgen.test.collectionbasictype;
2+
3+
import javax.persistence.Entity;
4+
5+
@Entity(name = "ConcreteLike")
6+
public class ConcreteLike extends Like<ConcreteLike.Target> {
7+
8+
@Override
9+
public Reference<Target> getObject() {
10+
return new Reference<>();
11+
}
12+
13+
public static class Target implements Like.I1, Like.I2 {
14+
}
15+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.hibernate.jpamodelgen.test.collectionbasictype;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.Id;
5+
import javax.persistence.Inheritance;
6+
import javax.persistence.InheritanceType;
7+
8+
/**
9+
* @author Thomas Heigl
10+
*/
11+
@Entity
12+
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
13+
public abstract class Like<T extends Like.I1 & Like.I2> {
14+
15+
@Id
16+
private Long id;
17+
18+
public abstract Reference<T> getObject();
19+
20+
interface I1 {
21+
}
22+
23+
interface I2 {
24+
}
25+
26+
public static class Reference<T> {
27+
}
28+
29+
}

0 commit comments

Comments
 (0)