-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Comments
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. Since you are asking on the Spring Data JPA issue tracker about JPA, this Stackoverflow about their relation might be of interest for you. |
Recently, I provide a criteria extension, which can implement the feature of dynamic sql. 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);
} |
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?
The text was updated successfully, but these errors were encountered: