Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JpaQueryCreator should deduplicate multi-select selections [DATAJPA-1029] #1375

Closed
spring-projects-issues opened this issue Dec 21, 2016 · 2 comments
Assignees
Labels
in: core type: bug
Milestone

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Dec 21, 2016

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:

java.lang.IllegalArgumentException: Multi-select expressions defined duplicate alias : id

I traced this back to two main causes:

  1. Commons' DefaultProjectionInformation returns duplicate properties from {{getInputProperties()}
  2. 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)


Affects: 1.11 M1 (Ingalls), 1.10.5 (Hopper SR5), 2.0 M1 (Kay)

Issue Links:

  • DATACMNS-963 ReturnedType.getInputProperties() does not guarantee distinct properties
    ("depends on")

Backported to: 1.11 RC1 (Ingalls), 1.10.6 (Hopper SR6)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 21, 2016

Oliver Drotbohm commented

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

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 21, 2016

Oliver Drotbohm commented

Should be fixed with the upstream fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants