Trying to test if a LocalDate contains a given year, day or month.
For example, given the criteria "1979", I'd like filter the rows returned by a findAll(Example<S> example)
JPA query in such way that it will return any row containing "1979".
The "problem" is that the entity defines the date (let say a birth date) as a LocalDate
and as such, doing:
ExampleMatcher personFilter = ExampleMatcher.matchingAll()
.withMatcher("birthDate", ExampleMatcher.GenericPropertyMatchers
.contains().ignoreCase());
personPage = repository.findAll(personFilter);
with PersonFilter#birthDate being itself a LocalDate
.
Basically, I would have to have this entity to declare the birth date as a String for the filter to work, but that is not possible as the DB itself store it as a date
.
Is there a way to solve such problem ? Like overriding the way the matching work ?