Description
It works fine with 2.7 but failed with 3.0.
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the given name [ringIndex] on this ManagedType [java.lang.Object]
at org.hibernate.metamodel.model.domain.AbstractManagedType.checkNotNull(AbstractManagedType.java:225) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.metamodel.model.domain.AbstractManagedType.getAttribute(AbstractManagedType.java:148) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.metamodel.model.domain.AbstractManagedType.getAttribute(AbstractManagedType.java:43) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.springframework.data.jpa.repository.query.QueryUtils.requiresOuterJoin(QueryUtils.java:836) ~[spring-data-jpa-3.2.0.jar:3.2.0]
The hibernate team suggest it's should be fixed at Spring Data JPA side.
the JPA specification requires that generic attributes are reported as generic-ly typed. The resolution of an attribute’s concrete type is an internal mechanism used to make Hibernate queries work. Your change is not correct, and the issue described in this Jira is on Spring’s side so I suggest reporting it there.
As with Java's reflection API, EntityType.getAttribute() gives you a representation of the inherited attribute as it was declared in the supertype. It does not do substitution of generic type arguments from the inheriting subclass, and I don't see any support anywhere in the JPA API or specification which hints that it should.So I believe that it's correct for Hibernate to return Object.class here, and I think this PR should be closed.
see https://hibernate.atlassian.net/browse/HHH-16144 and hibernate/hibernate-orm#7630