Uploaded image for project: 'Hibernate ORM'
  1. HHH-10261

Creating an entity sub graph on inherited attribute fails

    Details

      Description

      Having a mapped super class:

      @MappedSuperclass
      public class MappedSupperclass {
          @OneToOne(fetch = FetchType.LAZY)
          public Bar bar;
      }
      

      And extending class Foo:

      @Entity
      public class Foo extends MappedSupperclass {
      }
      

      Trying to add Subgraph:

      EntityGraph<Foo> entityGraph = em.createEntityGraph( Foo.class );
      entityGraph.addSubgraph( "bar" );
      

      Throws exception:

      org.hibernate.MappingException: Unknown entity: com.example.hibernate.bugs.inherited.MappedSupperclass
      	at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:776)
      	at org.hibernate.jpa.internal.metamodel.Helper.resolveAttributeSource(Helper.java:47)
      	at org.hibernate.jpa.internal.metamodel.Helper.resolveType(Helper.java:96)
      	at org.hibernate.jpa.graph.internal.AttributeNodeImpl.internalMakeSubgraph(AttributeNodeImpl.java:123)
      	at org.hibernate.jpa.graph.internal.AttributeNodeImpl.makeSubgraph(AttributeNodeImpl.java:98)
      	at org.hibernate.jpa.graph.internal.AbstractGraphNode.addSubgraph(AbstractGraphNode.java:159)
      	at org.hibernate.jpa.graph.internal.EntityGraphImpl.addSubgraph(EntityGraphImpl.java:81)
      	at org.hibernate.jpa.graph.internal.EntityGraphImpl.addSubgraph(EntityGraphImpl.java:26)
      	at com.example.hibernate.bugs.inherited.InheritedEntityGraphTest.attributeNodeInheritanceTest(InheritedEntityGraphTest.java:71)
      

      Reason:
      In AttributeNodeImpl,internalMakeSubgraph the declaring type of the attribute is used not the queried managed type.

      PR will follow

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: