HHH-14264 fix bug that entity graph cannot be applied to child entity class
This commit is contained in:
parent
88acc9511b
commit
962884a8dd
|
@ -16,6 +16,7 @@ import org.hibernate.graph.spi.RootGraphImplementor;
|
|||
import org.hibernate.graph.spi.SubGraphImplementor;
|
||||
import org.hibernate.metamodel.model.domain.spi.EntityTypeDescriptor;
|
||||
import org.hibernate.metamodel.model.domain.spi.IdentifiableTypeDescriptor;
|
||||
import org.hibernate.metamodel.model.domain.spi.ManagedTypeDescriptor;
|
||||
|
||||
/**
|
||||
* The Hibernate implementation of the JPA EntityGraph contract.
|
||||
|
@ -79,13 +80,14 @@ public class RootGraphImpl<J> extends AbstractGraph<J> implements EntityGraph<J>
|
|||
|
||||
@Override
|
||||
public boolean appliesTo(EntityTypeDescriptor<? super J> entityType) {
|
||||
if ( this.getGraphedType().equals( entityType ) ) {
|
||||
final ManagedTypeDescriptor<J> managedTypeDescriptor = getGraphedType();
|
||||
if ( managedTypeDescriptor.equals( entityType ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IdentifiableTypeDescriptor superType = entityType.getSupertype();
|
||||
IdentifiableTypeDescriptor<? super J> superType = entityType.getSupertype();
|
||||
while ( superType != null ) {
|
||||
if ( superType.equals( entityType ) ) {
|
||||
if ( managedTypeDescriptor.equals( superType ) ) {
|
||||
return true;
|
||||
}
|
||||
superType = superType.getSupertype();
|
||||
|
|
|
@ -9,6 +9,9 @@ package org.hibernate.graph;
|
|||
import javax.persistence.EntityGraph;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.graph.spi.RootGraphImplementor;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -189,4 +192,11 @@ public class EntityGraphsTest extends AbstractEntityGraphTest {
|
|||
EntityGraph<GraphParsingTestEntity> expected = parseGraph( "map.value(name, description) " );
|
||||
checkMerge( expected, g1, g2 );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-14264" )
|
||||
public void testRootGraphAppliesToChildEntityClass() {
|
||||
RootGraphImplementor<GraphParsingTestEntity> rootGraphImplementor = parseGraph( GraphParsingTestEntity.class, "name, description" );
|
||||
Assert.assertTrue( rootGraphImplementor.appliesTo( GraphParsingTestSubentity.class ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue