I am using the QueryDSL predicate object with spring REST endpoint to retrieve and query parameter values.
@GetMapping("/{subjectId}/students")
@RolesAllowed( {Roles.PLATFORM_ADMIN, Roles.USER})
public List<StudentResponse> getAllStudents(@PathVariable final String subjectId,
@QuerydslPredicate(root = Student.class) final Predicate predicate) {
final Predicate searchPredicate = studentPredicate()
.predicate(predicate)
.subjectId(subjectId)
.build();
return studentService.findBySubjectId(subjectId, searchPredicate);
}
The student class contains the studentId and studentName attributes ;
Now, if someone calls https: // hostname / {subjectId} / students? studentId = 1234 & studentName = test
Then the above code generates a predicate object with parameters. But I need to get above 2 parameter values from the predicate object for further processing, except for the db request. I do not see any helper method from the predicate object to retrieve the values. So how can I do this?
source
share