Closed
Description
Hi
I have a repository with the following method:
Window<Order> findAllBy(ScrollPosition position,
Sort sort);
I tried to use keyset-scrolling and specified createdAt and id as keyset properties. Also I added "createdAt" to sort properties:
orders = orderRepository.findAllBy(
ScrollPosition.forward(Map.of("id", id,
"createdAt", LocalDateTime.now())),
Sort.by("createdAt"));
The resulting SQL query uses following sort order: firstly createdAt, then id:
from ORDERS o1_0 where o1_0.createdAt>? or o1_0.createdAt=? and o1_0.id>? order by o1_0.createdAt,o1_0.id
But I need the opposite order (id and then createdAt). So I added "id" property to the Sort.by construction:
orders = orderRepository.findAllBy(
ScrollPosition.forward(Map.of("id", id,
"createdAt", LocalDateTime.now())),
Sort.by("id", "createdAt"));
However the resulting SQL query contains ORDER BY clause where "id" column is specified twice:
from ORDERS o1_0 where o1_0.id>? or o1_0.id=? and o1_0.createdAt>? or o1_0.id=? and o1_0.createdAt=? and o1_0.id>? order by o1_0.id,o1_0.createdAt,o1_0.id