I need to implement complex search feature using Spring Boot REST and Spring Data JPA using Criteria API. I need to provide RPIs like below
/college?select=*&where=name:DemoCollege
and location:LA
and staff{firstName:foo, lastName:boo, workExp>10}
and type in [1,2,3]
Collage object has name
, location
, type
fields and staff
list.
It has onetomany
relationship with Staff
so College
can have one or many Staff members.
based on the uri I need to build query using criteria api.
I am finding it very complex to implement the toPredicate()
method of org.springframework.data.jpa.domain.Specification
. Is there any such example handing such complex search filters?
Thanks in advance.