I'm using Spring JPA and get list of data by using Example Matcher. Source code below:
public Page<TranxLog> findAllByConditions(TranxReportFormModel formModel, Pageable page) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withNullHandler(ExampleMatcher.NullHandler.IGNORE)
.withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)
.withIgnoreCase()
.withIgnoreNullValues();
Example<TranxLog> example = Example.of(formModel.getTranxLog(), matcher);
return tranxlogRepository.findAll(example, page);
}
Now, I have search page, which have formDate
and toDate
and it has to be compared with field DateTime
in TranxLog
.
I tried to use .withMatcher()
but cannot find a way to compare a date.
Any idea? Thanks.
You can't do that with query-by-example. Probably the best is to construct a
Specification