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

support dynamic sql like mybatis with xml #2724

Closed
albert-get opened this issue Dec 9, 2022 · 2 comments
Closed

support dynamic sql like mybatis with xml #2724

albert-get opened this issue Dec 9, 2022 · 2 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@albert-get
Copy link

when i use jpa,api is very easy to use.but sometimes,i have to create sql string by self,because of @query is not dynamic sql that is not suitable.mybatis can create dynamic sql in xml,it is really easy to understand by everyone,and it is a good standard.jpa will support this?

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

JPA itself has the Criteria API for creating dynamic queries. You may use it in custom method implementations or via Specifications in Spring Data JPA.

There is also integration with Querydsl which serves a similar purpose but is nicer to use than the Criteria API.

An integration of Spring Data JPA with Mybatis is not planned.
We can't speak for JPA but I consider it highly unlikely that a standard will offer integration with a proprietary library.

Since you are asking on the Spring Data JPA issue tracker about JPA, this Stackoverflow about their relation might be of interest for you.

@schauder schauder closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2022
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 12, 2022
@holmofy
Copy link

holmofy commented May 15, 2024

Recently, I provide a criteria extension, which can implement the feature of dynamic sql.
https://github.com/holmofy/spring-data-criteria

It is based on the Criteria API specification of JPA.

default Page<User> searchByQuery(UserQuery query, Pageable pageable) {
    return findAll(Criteria.from(eq(User_.province, query.province))
                    .and(eq(User_.city, query.city))
                    .and(like(User_.area, query.area))
                    .and(like(User_.name, query.nick))
                    .and(between(User_.created, query.createFrom, query.createTo))
            , pageable);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants