holmofy / spring-data-criteria

`Spring Data Criteria` extends Spring Data JDBC & R2DBC & JPA to support dynamic sql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status(https://github.com/holmofy/spring-data-jdbc-criteria/actions/workflows/package.yaml/badge.svg)

Spring Data Criteria extends Spring Data JDBC & Spring Data R2DBC & Spring Data JPA to support dynamic sql.

to see DATAJDBC-319, DATAJPA-2724.

The usage is as follows:

public interface UserDao extends ListCrudRepository<User, Long>, CriteriaExecutor<User> {
    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);
    }
}

It will dynamically generate sql based on whether the query field is empty.

How to use

About

`Spring Data Criteria` extends Spring Data JDBC & R2DBC & JPA to support dynamic sql

License:Apache License 2.0


Languages

Language:Java 100.0%