spring-projects / spring-data-mongodb

Provides support to increase developer productivity in Java when using MongoDB. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-mongodb/
Apache License 2.0
1.59k stars 1.07k forks source link

querydsl predicate using IN operator returns no results with @DBRef #4716

Closed hhamzic1 closed 1 week ago

hhamzic1 commented 1 month ago

I'm having this setup:

public class BulkEntity {

    @Id
    private String id;

    @NotNull
    private Long bulkId;

    @NotNull
    private String bulkName;

    @NotNull
    @DBRef
    private OperatorEntity operator;
}

and

public class OperatorEntity {

    private String id;

    @NotNull
    private String name;
}

the corresponding QBulkEntity and QOperatorEntity classes are generated and I see no problem with them, but when I try to call bulkRepository.findAll with predicate that uses IN operator it doesn't work (returns no results)

example:

var operatorIds = List.of("6659aaf9e6f5547ba1e1aca5", "6659aaf9e6f5547ba1e1aca7");
var operatorIdPath = Expressions.stringPath("operator.id");
var predicate = operatorIdPath.in(operatorIds);
var entityPage = bulkRepository.findAll(predicate);

entityPage returns no result, even though entities with the ID's are present in 'operators' collection.

Is this an issue or I'm doing something wrong?

I found similar ticket that explains this problem back in 2017

versions that I use are:

spring-boot-starter-data-mongodb (3.3.0)
querydsl-mongodb (5.1.0)
querydsl-apt (5.1.0)
morphia (1.3.2)
christophstrobl commented 3 weeks ago

thanks for reporting - to speed things up a bit, do you have a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem?

spring-projects-issues commented 2 weeks ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 1 week ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.