select * from test where id = 1 and created_at > '2021-05-20 00:00:00.000'
正确的mybaits代码如下:
MyExample example = new MyExample();
MyExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(sendStatus);
criteria.andCreatedAtGreaterThan(createdAt);
mapper().selectByExample(example);
但我实现如下(**select * from test where id = 1:
MyExample example = new MyExample();
example.createCriteria().andIdEqualTo(sendStatus);
example.createCriteria().andCreatedAtGreaterThan(createdAt);
mapper().selectByExample(example);
它会导致不好的结果并且很难被发现。那么如何通过一些代码starategy避免mybatis使用两个Criteria?有人可以给我一些建议吗?
谢谢。