|
30 | 30 | import org.socialsignin.spring.data.dynamodb.mapping.DefaultDynamoDBDateMarshaller;
|
31 | 31 | import org.socialsignin.spring.data.dynamodb.query.Query;
|
32 | 32 | import org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBEntityInformation;
|
| 33 | +import org.springframework.data.domain.Pageable; |
33 | 34 | import org.springframework.data.domain.Sort;
|
34 | 35 | import org.springframework.data.domain.Sort.Direction;
|
35 | 36 | import org.springframework.data.domain.Sort.Order;
|
@@ -63,6 +64,7 @@ public abstract class AbstractDynamoDBQueryCriteria<T, ID extends Serializable>
|
63 | 64 | protected Object hashKeyPropertyValue;
|
64 | 65 | protected String globalSecondaryIndexName;
|
65 | 66 | protected Sort sort;
|
| 67 | + protected Pageable pageable; |
66 | 68 |
|
67 | 69 | public abstract boolean isApplicableForLoad();
|
68 | 70 |
|
@@ -111,9 +113,16 @@ protected QueryRequest buildQueryRequest(String tableName, String theIndexName,
|
111 | 113 | queryRequest.setSelect(Select.ALL_PROJECTED_ATTRIBUTES);
|
112 | 114 | applySortIfSpecified(queryRequest, new ArrayList<String>(new HashSet<String>(allowedSortProperties)));
|
113 | 115 | }
|
| 116 | + applyPageableIfSpecified(queryRequest); |
114 | 117 | return queryRequest;
|
115 | 118 | }
|
116 | 119 |
|
| 120 | + private void applyPageableIfSpecified(QueryRequest queryRequest) { |
| 121 | + if (pageable != null) { |
| 122 | + queryRequest.setLimit(pageable.getPageSize()); |
| 123 | + } |
| 124 | + } |
| 125 | + |
117 | 126 | protected void applySortIfSpecified(DynamoDBQueryExpression<T> queryExpression, List<String> permittedPropertyNames) {
|
118 | 127 | if (permittedPropertyNames.size() > 1) {
|
119 | 128 | throw new UnsupportedOperationException("Can only sort by at most a single range or index range key");
|
@@ -631,4 +640,10 @@ public DynamoDBQueryCriteria<T, ID> withSort(Sort sort) {
|
631 | 640 | return this;
|
632 | 641 | }
|
633 | 642 |
|
| 643 | + @Override |
| 644 | + public DynamoDBQueryCriteria<T, ID> withPageable(Pageable pageable) { |
| 645 | + this.pageable = pageable; |
| 646 | + return this; |
| 647 | + } |
| 648 | + |
634 | 649 | }
|
0 commit comments