8
votes

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

1 Answers

9
votes

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.