Skip to content

References not handled correctly when using QueryDSL [DATAMONGO-1394] #2307

Closed
@spring-projects-issues

Description

@spring-projects-issues

Simone Coletti opened DATAMONGO-1394 and commented

Trying to use eq on reference's $id, with no luck.

This is an example code:

public class Book {
     @DBRef
     private Library library;
} 
public class Library {
     @Id
     private String id;
}
String library_id = [SOME_ID];
QBook book = QBook.book;
BooleanExpression exp = book.library.id.eq(library_id);
    
List<Book> list = bookRepository.findAll(exp);  // EMPTY

Doing:

Library library = libraryRepository.findById(library_id);
QBook book = QBook.book;
BooleanExpression exp = book.library.eq(library);

List<Book> list = bookRepository.findAll(exp);  // EXPECTED ITEMS

or:

List<Book> list = bookRepository.findByLibraryId(library_id) // EXPECTED ITEMS

Affects: 1.8.1 (Gosling SR1)

Reference URL: #203

Issue Links:

Referenced from: pull request #373

Metadata

Metadata

Labels

in: mappingMapping and conversion infrastructurein: repositoryRepositories abstractiontype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions