8

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 :

Community
  • 1
  • 1
Israel Perales
  • 2,192
  • 2
  • 25
  • 30

1 Answers1

9

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.

Oliver Drotbohm
  • 80,157
  • 18
  • 225
  • 211
  • i prefer make a dao and use hibernate criteria for this purpose for now , i need study this case and how to combine with hibernate-search, thanks , great project – Israel Perales Dec 28 '16 at 22:29