spring-projects / spring-projects/spring-data-commons

QueryDSL: Struggling with syntax on how to bind for a sub-list field with QList [DATACMNS-1298]

Open
#1,740 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

in: repository type: bug
Dominant language
Java
Stars
838
Forks
730
PR merge metrics
No merged PRs in 30d

Description

GT opened DATACMNS-1298 and commented

I apologize as I am little confused if this is a QueryDSL issue or else a Spring QueryDSL extension issue. I have explained the issue in QueryDSL github forum -

https://github.com/querydsl/querydsl/issues/2293

To add further, I am using those generated class of QType with Spring Data Web support. With that class structure, I am unable to pass requestParameters as -

emails.email.value=johndoe@rocketmail.com
neither
emails.value=johndoe@rocketmail.com

Both of above fails because of invalid field on QList type as emails type is QList in generated code.

If i just use emails.value = johndoe@RocketEmail.com

then i am forced to register a String to List<Email> converter which i feel like shouldn;t be required.

My API method is very simplistic -

public ResponseEntity<Users> searchUser(@ApiIgnore @QuerydslPredicate(root = User.class) Predicate predicate) {
        if (predicate == null || (BooleanBuilder.class.isAssignableFrom(predicate.getClass()) && !((BooleanBuilder)
                predicate).hasValue())) {
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        } else {
            Users result = StreamSupport.stream(this.userRepository.findAll(predicate)
                                                                   .spliterator(), false)
                                        .collect
                                                (Collectors
                                                         .toCollection(() -> new Users()));
            return ResponseEntity.ok(result);
        }

Appreciate any guidance on how can I bind to sub-lists which are generated as QList and not as ListPath


Affects: 2.0.6 (Kay SR6)

Reference URL: https://github.com/querydsl/querydsl/issues/2293

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.