How to add restriction to range between two dates

2019-05-02 17:11发布

I have one class with two dates and my search is dynamic, Hibernate provides Query By Example (QBE), but now use QBE of Spring Data. The problem is when created a QBE but the documentation restrict the ExampleMatcher for String types, i need create a ExampleMatcher for search all entities between in this dates.

How implement this using query by example?.

My alternatives for now is:

Example properties for class:

  private int id;
  private String property1;
  private String property2;
  private Date dateFirst;
  private Date dateSecond;

Related :

1条回答
闹够了就滚
2楼-- · 2019-05-02 17:43

The short answer is, you don't. Query by example is considered exactly what its name suggests: you give an example and the query is built on a match of the given fields. That's also documented in the "Limitations" section of the reference documentation you linked to.

For more advanced use cases and predicate definitions, have a look at the Querydsl support.

查看更多
登录 后发表回答