msuzuki
msuzuki

Reputation: 145

Spring Batch JdbcPagingItemReader sort by two columns/keys

I have this JdbcPagingItem reader and I want to sort by 2 columns.

Map<String, Order> sortKey = new HashMap<>();
sortKey.put("xbin", Order.ASCENDING);
sortKey.put("ybin", Order.ASCENDING);

Since the sortKey is a Map, I think this should work.

I need some confirmation if this is how I am supposed to do?

thx, Markus.

Upvotes: 0

Views: 1031

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31600

Yes, you can sort items by multiple columns and your code snippet is correct. The resulting query performed by the item reader will be something like:

select ... from table .. ORDER BY xbin ASC, ybin ASC

Upvotes: 1

Related Questions