I am stuck on the pagination part for the interface based projection. So basically I am using an interface for the projection and building my custom response. This is the sample query
@Query(value = "SELECT course AS courseName, teacher as teacherName, student AS studentName FROM table WHERE id = ?1 AND created_date <= ?2 AND created_date >= ?3 ")
Page<CustomResult> getData(UUID id, LocalDateTime date, LocalDateTime date1, Pageable pageable);
And this my interface
public interface CustomResult {
String getCourseName();
String getTeacherName();
String getStudentName();
}
I am able to achieve the pagination here and I am getting the desired result something like this
{
"_embedded": {
"tupleBackedMaps": [
{
"courseName": "",
"teacherName": "",
"studentName": ""
},
{
"courseName": "",
"teacherName": "",
"studentName": ""
}
]
},
"_links": {},
"page": {
"size": 10,
"totalElements": 2,
"totalPage": 1,
"number": 0
}
}
But my problem here is little different I want to change the key name here tupleBackedMaps
to somethingElse
. And I also want to do the ordering of elements in the result. But I don't know how to do that with interface based projection.
If it was a class based projection I know there is something called RepresentationModel
which can be used and @Relation
and JsonOrder
can be used to achieve what I want. But I don't know how to do this with interface.
Is there a way ? Please let me know if there is any other way or workaround ?