Skip to content

Commit ac7feff

Browse files
committed
HHH-6500 : EntityBinding.getEntity().getSuperType() is null for subclass EntityBinding
1 parent b269262 commit ac7feff

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/source/binder/Binder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private EntityBinding buildBasicEntityBinding(EntitySource entitySource, EntityB
201201
entityName,
202202
className,
203203
currentBindingContext.makeClassReference( className ),
204-
null
204+
superEntityBinding == null ? null : superEntityBinding.getEntity()
205205
);
206206
entityBinding.setEntity( entity );
207207

hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/entity/InheritanceBindingTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import static junit.framework.Assert.assertEquals;
3838
import static junit.framework.Assert.assertFalse;
39+
import static junit.framework.Assert.assertNotNull;
3940
import static junit.framework.Assert.assertNull;
4041
import static junit.framework.Assert.assertSame;
4142
import static junit.framework.Assert.assertTrue;
@@ -58,6 +59,23 @@ public void testDiscriminatorValue() {
5859
assertEquals( "Wrong discriminator value", "foo", entityBinding.getDiscriminatorMatchValue() );
5960
}
6061

62+
@Test
63+
@Resources(annotatedClasses = { RootOfSingleTableInheritance.class, SubclassOfSingleTableInheritance.class })
64+
public void testSubclassEntitySuperType() {
65+
EntityBinding entityBinding = getEntityBinding( SubclassOfSingleTableInheritance.class );
66+
assertNotNull( entityBinding.getEntity().getSuperType() );
67+
assertSame( RootOfSingleTableInheritance.class, entityBinding.getEntity().getSuperType().getClassReference() );
68+
assertEquals( RootOfSingleTableInheritance.class.getName(), entityBinding.getEntity().getSuperType().getClassName() );
69+
assertNull( entityBinding.getEntity().getSuperType().getSuperType() );
70+
}
71+
72+
@Test
73+
@Resources(annotatedClasses = { RootOfSingleTableInheritance.class, SubclassOfSingleTableInheritance.class })
74+
public void testRootEntitySuperType() {
75+
EntityBinding entityBinding = getEntityBinding( RootOfSingleTableInheritance.class );
76+
assertNull( entityBinding.getEntity().getSuperType() );
77+
}
78+
6179
@Test
6280
@Resources(annotatedClasses = {
6381
SubclassOfSingleTableInheritance.class,

0 commit comments

Comments
 (0)