I have this Endpoint in my controller:
@GetMapping("/validationsList/{search}")
public ResponseEntity<Page<IntRaptMecListDTO>> getListOfAppointmentsBySearch(
@RequestParam(value="page", defaultValue="0") Integer page,
@RequestParam(value="linesPerPage", defaultValue="24") Integer linesPerPage,
@RequestParam(value="orderBy", defaultValue="dtOperacao") String orderBy,
@RequestParam(value="direction", defaultValue="DESC") String direction,
@PathVariable(value="search") String search) {
if( search != null && !search.equals("") && !search.trim().equals("")) {
Page<IntRaptMec> pointList = intRaptMecService.findPageBySearch(page, linesPerPage, orderBy, direction, search);
Page<IntRaptMecListDTO> smallPointList = pointList.map(obj -> intRaptMecService.appointmentToListDTO(obj));
return ResponseEntity.ok().body(smallPointList);
} else {
return null;
}
}
The findPageBySearch method has this structure:
public Page<IntRaptMec> findPageBySearch(Integer page, Integer linesPerPage, String orderBy, String direction, String search){
PageRequest pageRequest = PageRequest.of(page, linesPerPage, Direction.valueOf(direction), orderBy);
return intRaptMecRepository.findAllByParameters(search, pageRequest);
}
And the repository has this structure
@Repository
@Transactional
public interface IntRaptMecRepository extends JpaRepository<IntRaptMec, Long>{
@Query("SELECT int FROM IntRaptMec int "
+ "INNER JOIN Funcionar f ON f.cdFunc = int.cdFunc "
+ "INNER JOIN Empresa e ON e.cdEmpresa = int.instancia "
+ "WHERE UPPER(f.deFunc) LIKE UPPER(?1) OR UPPER(e.deEmpresa) LIKE UPPER(?1)")
Page<IntRaptMec> findAllByParameters(String search, Pageable pageable);
}
If I do a direct SELECT in SQL Developer, the lines return normally:
But when I send to spring it simply does not return any results, and it goes like this in the debug:
"Page 1 of 0 containing UNKNOWN instances"
What am I doing wrong?