Using projection interfaces with inheritance might lead to occassions where JpaQueryCreator tries to create queries with duplicate multi-select aliases.
For example resulting in exceptions like these:
java.lang.IllegalArgumentException: Multi-select expressions defined duplicate alias : id
I traced this back to two main causes:
Commons' DefaultProjectionInformation returns duplicate properties from {{getInputProperties()}
JpaQueryCreator uses these properties as is to create the multi-select
I'm not entirely sure, if that duplicated information might be of some use in other implementations, but JPA / Hibernate is definitely having a problem with those.
A simple suggestion to solve the problem would be to use a HashSet instead of an ArrayList in JpaQueryCreator#complete(Predicate, Sort, CriteriaQuery, CriteriaBuilder, Root)
There actually is a distinct() in DefaultProjectionInformation.getInputProperties() but that of course fails as in an inheritance hierarchy the PropertyDescriptor instances are not considered equal for properties of different types. I'm gonna fix that in ReturnedType when we map those descriptors to to property names. Follow DATACMNS-963 for details. That should make the downstream JpaQueryCreator work as expected then
Sebastian Staudt opened DATAJPA-1029 and commented
Using projection interfaces with inheritance might lead to occassions where JpaQueryCreator tries to create queries with duplicate multi-select aliases.
For example resulting in exceptions like these:
I traced this back to two main causes:
DefaultProjectionInformation
returns duplicate properties from {{getInputProperties()}JpaQueryCreator
uses these properties as is to create the multi-selectI'm not entirely sure, if that duplicated information might be of some use in other implementations, but JPA / Hibernate is definitely having a problem with those.
A simple suggestion to solve the problem would be to use a
HashSet
instead of anArrayList
inJpaQueryCreator#complete(Predicate, Sort, CriteriaQuery, CriteriaBuilder, Root)
Affects: 1.11 M1 (Ingalls), 1.10.5 (Hopper SR5), 2.0 M1 (Kay)
Issue Links:
("depends on")
Backported to: 1.11 RC1 (Ingalls), 1.10.6 (Hopper SR6)
The text was updated successfully, but these errors were encountered: