-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-1454 - Add support for exists projection in repository query methods. #381
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
Conversation
* @since 1.10 | ||
* @return | ||
*/ | ||
boolean exists() default false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could derive that from the return type of the query method instead. Queries on MongoDB always return a document which can't be mapped to a boolean
naturally. So we could just enable the exists execution for all query methods that return a boolean
, can't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for string-based queries quite well. I added a commit to derive count queries from a long
return type.
c01a004
to
6743f4b
Compare
…y methods. Prepare issue branch.
6743f4b
to
6fa3a86
Compare
…y methods. We now support exists projections for query methods in query methods for derived and string queries. public PersonReposotiry extends Repository<Person, String> { boolean existsByFirstname(String firstname); @ExistsQuery(value = "{ 'lastname' : ?0 }") boolean someExistQuery(String lastname); @query(value = "{ 'lastname' : ?0 }", exists = true) boolean anotherExistQuery(String lastname); }
6fa3a86
to
9d9fbfd
Compare
…y methods. We now support exists projections for query methods in query methods for derived and string queries. public PersonRepository extends Repository<Person, String> { boolean existsByFirstname(String firstname); @ExistsQuery(value = "{ 'lastname' : ?0 }") boolean someExistQuery(String lastname); @query(value = "{ 'lastname' : ?0 }", exists = true) boolean anotherExistQuery(String lastname); } Original pull request: #381.
Formatting in test case. Original pull request: #381.
…y methods. We now support exists projections for query methods in query methods for derived and string queries. public PersonRepository extends Repository<Person, String> { boolean existsByFirstname(String firstname); @ExistsQuery(value = "{ 'lastname' : ?0 }") boolean someExistQuery(String lastname); @query(value = "{ 'lastname' : ?0 }", exists = true) boolean anotherExistQuery(String lastname); } Original pull request: #381.
Formatting in test case. Original pull request: #381.
We now support exists projections for query methods in query methods for derived and string queries.
Related ticket: DATAMONGO-1454
Depends on: spring-projects/spring-data-commons#171