spring-projects / spring-projects/spring-data-ldap
Predicate fails with message: Unsupported operator IN [DATALDAP-62]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 96
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
Alex opened DATALDAP-62 and commented
I have a POJO class that contains LDAP attributes. The class is annotated with @Entry annotation. The entity has some fields as a collection (i.e. Set<String>) but most of the POJO fields are just String values.
When I try to use LdapRepository's findAll method with Predicate to search through multi-valued fields with using Collection.contains(...) method the spring-data-ldap throws the exception:
java.lang.UnsupportedOperationException: Unsupported operator IN
at org.springframework.data.ldap.repository.support.LdapSerializer.visit(LdapSerializer.java:108)
at org.springframework.data.ldap.repository.support.LdapSerializer.visit(LdapSerializer.java:37)
at com.querydsl.core.types.OperationImpl.accept(OperationImpl.java:83)
I was able to trace the problem and it looks like when Collection type of an attribute is used for a Predicate's query then QueryDSL provides IN operation which is not supported by Spring's LdapSerializer class.
Here is the sample of the Predicate:
QPerson person = QPerson.person;
return person.studentAliases.contains(alias).or(person.employeeAliases.contains(alias));
Is it possible to add support for IN operation same way as EQ operator so DATA-LDAP module processes multi-valued attributes without any issues?
No further details from DATALDAP-62
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in org.springframework.data.ldap.repository.support.LdapSerializer, especially visit at lines 108 and 37, and trace how the QueryDSL contains predicate becomes the IN operation. Compare the unsupported IN handling with EQ handling, using the QPerson studentAliases and employeeAliases example. Done means collection-based predicates are serialized without the UnsupportedOperationException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100