Skip to content
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

Query by Example support #1192

Closed
zeljko-mirovic opened this issue Mar 5, 2022 · 5 comments
Closed

Query by Example support #1192

zeljko-mirovic opened this issue Mar 5, 2022 · 5 comments
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@zeljko-mirovic
Copy link

I am a bit confused by #929.
Support for converting Example into Query/Criteria is added, but nothing else?
To use query by example in a repository, additional changes are needed in repository implementation and classes used by that implementation like JdbcAggregateTemplate and DataAccessStrategy?
Do you have a plan to continue with that?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 5, 2022
@schauder
Copy link
Contributor

schauder commented Mar 7, 2022

#929 together with 9336d09 implements Query By for Spring Data R2DBC.

Query By Example is currently not in the near future plans, but is certainly something we want to support eventually.

@schauder schauder added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 7, 2022
@mp911de mp911de added the status: ideal-for-contribution An issue that a contributor can help us with label Mar 7, 2022
@DiegoKrupitza
Copy link
Contributor

I can take a closer look at this.

DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Mar 11, 2022
This commit introduces the find by example method `findOne(Example<S> example)` to spring-data-jdbc. MyBatis implementation is missing since I do not have the knowledge for this.

Related tickets spring-projects#1192
@DiegoKrupitza
Copy link
Contributor

DiegoKrupitza commented Mar 11, 2022

I started with implementing "query by example" but I can't implement the MyBatis version of this since my MyBatis knowledge is none existing. I hope somebody can be found who implements this at a later point. Changes only need to be done within org.springframework.data.jdbc.mybatis.MyBatisDataAccessStrategy.java

DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Mar 11, 2022
This commit introduces the find by example method `findAll(...)` to spring-data-jdbc. MyBatis implementation is missing since I do not have the knowledge for this.

Related tickets spring-projects#1192
DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Mar 11, 2022
This commit introduces the exists by example method `exists(...)` to spring-data-jdbc. MyBatis implementation is missing since I do not have the knowledge for this.

Related tickets spring-projects#1192
DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Mar 12, 2022
This commit introduces the count by example method `count(...)` to spring-data-jdbc. MyBatis implementation is missing since I do not have the knowledge for this.

Related tickets spring-projects#1192
DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Mar 12, 2022
…le pageable)`.

This commit introduces the find by example pageable method `findAll(Example<S> example, Pageable pageable)` to spring-data-jdbc. MyBatis implementation is missing since I do not have the knowledge for this.

Related tickets spring-projects#1192
@DiegoKrupitza
Copy link
Contributor

DiegoKrupitza commented Mar 12, 2022

I implemented 6 out of the 7 methods provided by QueryByExampleExecutor.
The method findBy(Example<S> example, Function<FetchableFluentQuery<S>, R> queryFunction); is not implemented since I can't figure out what should happen here 😅 .

The MyBatis implementation is missing as already mentioned above.

Both are marked with UnsupportedOperationException.

DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Mar 12, 2022
Missing MyBatisDataAccessStrategy implementation and `findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction)` marked with `UnsupportedOperationException`.

Related tickets spring-projects#1192
@DiegoKrupitza
Copy link
Contributor

PR can be found here #1195

schauder added a commit that referenced this issue Jul 13, 2022
The use of QueryMapper caused dependency cycles.

Original pull request #1195
See #1192
schauder added a commit that referenced this issue Jul 13, 2022
schauder added a commit that referenced this issue Jul 13, 2022
Added `@since` comments for new methods and classes.
General formatting and code style tweaking.
Github references for new tests added.
Fixes for integration tests with various databases:
- Not all stores support submillisecond precision for Instant.
- Count for exists query doesn't work for all databases, nor does `LEAST(COUNT(1), 1)`
- MariaDB defaults timestamp columns to the current time.
- Ordering was applied twice.
- DATETIME in SqlServer has a most peculiar preceision. We switch to DATETIME2.

Original pull request #1195
See #1192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants