Skip to content

DATAMONGO-972 - Handle references correctly when using QueryDSL. #203

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

Closed
wants to merge 2 commits into from

Conversation

christophstrobl
Copy link
Member

!!! DO NOT MERGE !!! - it's a discussion base.

SpringDataMongodbSerializer now uses the overrides for isReference and asReference to create the appropriate DBRef when serializing.

Therefore we look for the meta-annotation @Reference and inspect the given Path to determine the property and its meta information like collection.

ATTENTION

Run it anyway
mvn -Dquerydsl=4.3.1 clean install

SpringDataMongodbSerializer now uses the overrides for isReference and asReference to create the appropriate DBRef objects when serializing. 

Therefore we look for the meta-annotation @reference and inspect the given Path to determine the property and its meta information like ‘collection’.

The change will only take effect when using QueryDSL 3.4.1 and above. See querydsl/querydsl#803 for details.
christophstrobl added a commit that referenced this pull request Jul 9, 2014
SpringDataMongodbSerializer now overrides the necessary methods to create the appropriate DBRef objects when serializing data via Querydsl.

We currently disable the test case as it the fix taking effect requires Querydsl 3.4.1 which unfortunately breaks Java 6 compatibility. We include the fix nonetheless to allow users on Java 7 to potentially use the latest Querydsl.

Original pull request: #203.
Related tickets: querydsl/querydsl#803.
christophstrobl added a commit that referenced this pull request Jul 9, 2014
SpringDataMongodbSerializer now overrides the necessary methods to create the appropriate DBRef objects when serializing data via Querydsl.

We currently disable the test case as it the fix taking effect requires Querydsl 3.4.1 which unfortunately breaks Java 6 compatibility. We include the fix nonetheless to allow users on Java 7 to potentially use the latest Querydsl.

Original pull request: #203.
Related tickets: querydsl/querydsl#803.
@odrotbohm
Copy link
Member

Applied to master and bugfix branch. Ignored test cases for now. See the ticket for details.

@odrotbohm odrotbohm closed this Jul 9, 2014
@odrotbohm odrotbohm deleted the issue/DATAMONGO-972 branch July 9, 2014 12:22
@simonered
Copy link

Seems not to work anymore.

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

This is my simplified 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

@christophstrobl
Copy link
Member Author

@simonered please open an issue in JIRA and provide versions of sd-mongodb and querydsl used. thanks!

@simonered
Copy link

Opened

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

Successfully merging this pull request may close these issues.

3 participants