|
24 | 24 | import org.springframework.data.relational.core.dialect.RenderContextFactory; |
25 | 25 | import org.springframework.data.relational.core.mapping.AggregatePath; |
26 | 26 | import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; |
| 27 | +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; |
27 | 28 | import org.springframework.data.relational.core.query.Criteria; |
28 | 29 | import org.springframework.data.relational.core.sql.*; |
29 | 30 | import org.springframework.data.relational.core.sql.render.SqlRenderer; |
@@ -222,11 +223,29 @@ Sort applyCriteriaOrderBy(Sort sort, @Nullable ScrollPosition scrollPosition) { |
222 | 223 | if (!(scrollPosition instanceof KeysetScrollPosition) || scrollPosition.isInitial()) |
223 | 224 | return sort; |
224 | 225 |
|
225 | | - Set<String> orders = sort.get().map(Sort.Order::getProperty).collect(Collectors.toSet()); |
| 226 | + Set<String> orders = sort.get() |
| 227 | + .map(Sort.Order::getProperty) |
| 228 | + .map(it -> { |
| 229 | + RelationalPersistentProperty prop = entity.getPersistentProperty(it); |
| 230 | + if (prop == null) |
| 231 | + return it; |
| 232 | + |
| 233 | + return prop.getColumnName().getReference(); |
| 234 | + }) |
| 235 | + .collect(Collectors.toSet()); |
226 | 236 |
|
227 | 237 | Set<String> keys = ((KeysetScrollPosition) scrollPosition).getKeys().keySet(); |
228 | 238 |
|
229 | | - Set<String> notSorted = keys.stream().filter(it -> !orders.contains(it)).collect(Collectors.toSet()); |
| 239 | + Set<String> notSorted = keys |
| 240 | + .stream() |
| 241 | + .map(it -> { |
| 242 | + RelationalPersistentProperty prop = entity.getPersistentProperty(it); |
| 243 | + if (prop == null) |
| 244 | + return it; |
| 245 | + |
| 246 | + return prop.getColumnName().getReference(); |
| 247 | + }) |
| 248 | + .filter(it -> orders.stream().noneMatch(order -> order.equalsIgnoreCase(it))).collect(Collectors.toSet()); |
230 | 249 |
|
231 | 250 | if (notSorted.isEmpty()) |
232 | 251 | return sort; |
@@ -267,6 +286,10 @@ Criteria buildKeysetCriteria(List<String> columns, List<Object> values, boolean |
267 | 286 | return Criteria.empty(); |
268 | 287 |
|
269 | 288 | String column = columns.get(0); |
| 289 | + RelationalPersistentProperty prop = entity.getPersistentProperty(column); |
| 290 | + if (prop != null) |
| 291 | + column = prop.getColumnName().getReference(); |
| 292 | + |
270 | 293 | Object value = values.get(0); |
271 | 294 |
|
272 | 295 | boolean isAscending = isForward ^ dir.isDescending(); |
|
0 commit comments