I have a general usage question regarding EntityGraphs, and specifically Hibernate's implementation.
The JPA specification, as codified by the EntityGraph<T> interface, specifies that an IllegalArgumentException is thrown if an attribute that is not an attribute of the entity type is being added: http://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/EntityGraph.html#addAttributeNodes(java.lang.String...)
However, it is unclear from the specification if it is legal to add inherited attributes, or not. For example: If Entity type E1 defines an attribute a1 and entity type E2 extends E1, is it legal to add a1 as an attribute to EntityGraph<E2>?
The Hibernate implementation throws an IllegalArgumentException if an inherited attribute is being added. Looking at the Hibernate code base, the implementation resolves attribute names using only those attributes directly declared by the entity type.
If this behavior conforms to the JPA specification then how is one supposed to add superclass attributes?
|