spring-boot-api-project-seed icon indicating copy to clipboard operation
spring-boot-api-project-seed copied to clipboard

findByCondition,查询条件的例子应该怎么写呀??

Open ithjz opened this issue 7 years ago • 3 comments

tk.mybatis.mapper.entity.Condition

我应该看哪篇博客,学习呀??

ithjz avatar Mar 26 '18 08:03 ithjz

        Condition condition = new Condition(User.class);
        condition.createCriteria()
            .andEqualTo("username","potato")
            .andEqualTo("sex",1);
        condition.orderBy("id").desc();
        userService.findByCondition(condition);
        // select * from user where username = 'potato' and sex = 1 order by id desc;

就是通过通过代码来拼SQL,你看看API估计就明白了,说白了就是一些 where 条件。

lihengming avatar Mar 26 '18 11:03 lihengming

非常简单明了,谢谢 我补充个 Condition condition = new Condition(goods.class); condition.createCriteria() .andLessThanOrEqualTo("totalWidth", max) .andGreaterThan("totalWidth", min); condition.orderBy("id").desc();

ithjz avatar Mar 27 '18 09:03 ithjz

good

lihengming avatar May 16 '18 12:05 lihengming