HHH-9080 - Can't add attribute node declared in superclass (inheritance) in EntityGraph
This commit is contained in:
parent
d591a3fd52
commit
b6a8352406
|
@ -136,7 +136,7 @@ public class EntityGraphImpl<T> extends AbstractGraphNode<T> implements EntityGr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Attribute<T,?> resolveAttribute(String attributeName) {
|
protected Attribute<T,?> resolveAttribute(String attributeName) {
|
||||||
final Attribute<T,?> attribute = entityType.getDeclaredAttribute( attributeName );
|
final Attribute attribute = entityType.getAttribute( attributeName );
|
||||||
if ( attribute == null ) {
|
if ( attribute == null ) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format(
|
String.format(
|
||||||
|
|
|
@ -225,7 +225,45 @@ public class EntityGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-9080")
|
||||||
|
public void attributeNodeInheritanceTest() {
|
||||||
|
EntityManager em = getOrCreateEntityManager();
|
||||||
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
Manager manager = new Manager();
|
||||||
|
em.persist( manager );
|
||||||
|
Employee employee = new Employee();
|
||||||
|
manager.friends.add( employee);
|
||||||
|
em.persist( employee );
|
||||||
|
Manager anotherManager = new Manager();
|
||||||
|
manager.managers.add(anotherManager);
|
||||||
|
em.persist( anotherManager );
|
||||||
|
em.getTransaction().commit();
|
||||||
|
em.clear();
|
||||||
|
|
||||||
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
EntityGraph<Manager> entityGraph = em.createEntityGraph( Manager.class );
|
||||||
|
entityGraph.addAttributeNodes( "friends" );
|
||||||
|
entityGraph.addAttributeNodes( "managers" );
|
||||||
|
|
||||||
|
Map<String, Object> properties = new HashMap<String, Object>();
|
||||||
|
properties.put( "javax.persistence.loadgraph", entityGraph );
|
||||||
|
|
||||||
|
Manager result = em.find( Manager.class, manager.id, properties );
|
||||||
|
|
||||||
|
assertTrue( Hibernate.isInitialized( result ) );
|
||||||
|
assertTrue( Hibernate.isInitialized( result.friends ) );
|
||||||
|
assertEquals( result.friends.size(), 1 );
|
||||||
|
assertTrue( Hibernate.isInitialized( result.managers) );
|
||||||
|
assertEquals( result.managers.size(), 1 );
|
||||||
|
|
||||||
|
em.getTransaction().commit();
|
||||||
|
em.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity
|
||||||
public static class Foo {
|
public static class Foo {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|
Loading…
Reference in New Issue