easybest / spring-data-mybatis

Simplifies the development of creating a MyBatis-based data access layer.
https://sdm.easybest.io
Apache License 2.0
237 stars 73 forks source link

Criteria query #270

Closed easybest closed 2 years ago

easybest commented 2 years ago

Supports criteria query, such as:

    @Test
    void testCriteria() {

        this.flushTestUsers();

        assertThat(this.repository.findAll(
                CriteriaQuery.lambda(User.class).eq(User::getFirstname, "Oliver").eq(User::getLastname, "Gierke")))
                        .containsOnly(this.firstUser);

        assertThat(this.repository.findAll(CriteriaQuery.create(User.class).eq("firstname", "Oliver")
                .custom("firstname like ?1", "old1").or().eq("lastname", "Gierke").or().eq("lastname", "DDD")
                .or(c -> c.eq("lastname", "XXX").ne("firstname", "CCC")))).containsOnly(this.firstUser);

    }