I need to find some objects for all 3 parameters from request with pagination:
@GetMapping public ResponseEntity<List<Role>> getRoles(@RequestParam(value = "name", required = false) String roleName, @RequestParam(value = "description", required = false) String roleDescription, @RequestParam(value = "status", required = false) String roleStatus, @RequestParam("page") int pageNumber, @RequestParam("size") int pageSize) { }
But if any one of parameters is null, i need to find objects for last 2 parameters, and if any 2 of parameters is null, have to find objects for last one parameters.
Please help, how can i do that searching easily with jpaRepository methods without many if cycles?
I read about JpaSpecificationExecutor and Specification. But I don’t fully understand, is this exactly what I need?
indie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.