微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在日期中使用Spring ExampleMatcher

如何解决如何在日期中使用Spring ExampleMatcher

我有Test类,其中有createddate字段,我们如何创建具有Pageable的Spring ExampleMatcher来基于createdDate过滤记录。

public class Test  {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long testId;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;
}

如果我通过日期 2020-06-03 ,则仅必须过滤具有给定日期的记录。 我已经尝试使用下面的代码,但是它不起作用。

Pageable pageable = PageRequest.of((int) pageNumber-1,recordSize,Sort.by("testId"));
Test test = new test();
ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("createdDate",ExampleMatcher.GenericPropertyMatchers.test());
Example<Test> appEntity = Example.of(test,matcher);
Page<Test> appPagelist = appRepository.findAll(appEntity,pageable);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。