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

Improve mongodb reference handling #803

Closed
timowest opened this Issue Jun 13, 2014 · 15 comments

Comments

Projects
None yet
2 participants
@timowest
Member

timowest commented Jun 13, 2014

In eq and ne operations reference cases are not handled properly.

timowest added a commit that referenced this issue Jun 13, 2014

@timowest timowest added the fixed label Jun 13, 2014

@timowest timowest added this to the 3.4.1 milestone Jun 13, 2014

@timowest timowest modified the milestone: 3.4.1 Jun 25, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jun 29, 2014

Member

Released in 3.4.1

Member

timowest commented Jun 29, 2014

Released in 3.4.1

@timowest timowest closed this Jun 29, 2014

christophstrobl added a commit to spring-projects/spring-data-mongodb that referenced this issue Jul 9, 2014

DATAMONGO-972 - Handle references correctly when using QueryDSL.
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 to spring-projects/spring-data-mongodb that referenced this issue Jul 9, 2014

DATAMONGO-972 - Querydsl integration now handles references correctly.
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 to spring-projects/spring-data-mongodb that referenced this issue Jul 9, 2014

DATAMONGO-972 - Querydsl integration now handles references correctly.
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.
@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Feb 29, 2016

Seems not working anymore...

Seems not working anymore...

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Feb 29, 2016

Member

@simonered What failure do you get? Which version?

Member

timowest commented Feb 29, 2016

@simonered What failure do you get? Which version?

@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Feb 29, 2016

Latest version (3.7.1)...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;
 }

[...]

QBook book = QBook.book;
BooleanExpression b = book.library.id.eq([some_id]);
Predicate p = ExpressionUtils.and(null, b);

List<Book> list = bookRepository.findAll(p);  // EMPTY

Custom method in mongo repository bookRepository.findByLibraryId(String id) returns the items i'm expecting

Latest version (3.7.1)...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;
 }

[...]

QBook book = QBook.book;
BooleanExpression b = book.library.id.eq([some_id]);
Predicate p = ExpressionUtils.and(null, b);

List<Book> list = bookRepository.findAll(p);  // EMPTY

Custom method in mongo repository bookRepository.findByLibraryId(String id) returns the items i'm expecting

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Feb 29, 2016

Member

is this with Spring Data?

Member

timowest commented Feb 29, 2016

is this with Spring Data?

@simonered

This comment has been minimized.

Show comment
Hide comment

Yes

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Feb 29, 2016

Member

then the related template methods might not have been overridden in the version you use.

Member

timowest commented Feb 29, 2016

then the related template methods might not have been overridden in the version you use.

@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Feb 29, 2016

The case is the same as the original StackOverflow question

The case is the same as the original StackOverflow question

@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Feb 29, 2016

What to you mean for "not been overridden"? What should I have to do?

What to you mean for "not been overridden"? What should I have to do?

@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Mar 1, 2016

So the issue is confirmed or should I have to do something else to make it work?

So the issue is confirmed or should I have to do something else to make it work?

@timowest

This comment has been minimized.

Show comment
Hide comment
@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Mar 5, 2016

I'm using Spring Data MongoDB 1.8.1 (coming from spring boot 1.3.2)

I'm using Spring Data MongoDB 1.8.1 (coming from spring boot 1.3.2)

@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Mar 7, 2016

Tried to update Spring Data to latest version 1.8.4, but the issue is still present.

Tried to update Spring Data to latest version 1.8.4, but the issue is still present.

@simonered

This comment has been minimized.

Show comment
Hide comment
@simonered

simonered Mar 8, 2016

I think the issue should be reopened.

I think the issue should be reopened.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 8, 2016

Member

The Spring Data Mongodb Querydsl bindings are maintained by Spring Data, not by us, it seems to be caused by their Querydsl bindings.

Member

timowest commented Mar 8, 2016

The Spring Data Mongodb Querydsl bindings are maintained by Spring Data, not by us, it seems to be caused by their Querydsl bindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment