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:
Create a hibernate dao and use QBE and criteria of hibernate (Bye JPA :'( )
Explore this http://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/ (really ugly code)
Example properties for class:
private int id;
private String property1;
private String property2;
private Date dateFirst;
private Date dateSecond;
Related :
http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#query-by-example.usage
How to combine multiple date-between searches with CrudRepository of Spring Data JPA?
Spring Data JPA: Query by Example?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With