Skip to content

Commit 91defe4

Browse files
committed
Merge branch 'develop'
# Conflicts: # README.md # pom.xml # src/changes/changes.xml # src/main/java/org/socialsignin/spring/data/dynamodb/repository/Query.java
2 parents 97441b3 + fb7c80f commit 91defe4

28 files changed

+568
-93
lines changed

CHANELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 5.2.4
2+
3+
## Housekeeping
4+
1. Built against Spring Data 2.3.0, not changes needed.
5+
6+
## Bug fixes
7+
1. [Missing LSI Indexes Projection Settings](https://github.com/boostchicken/spring-data-dynamodb/issues/19)
8+
2. [Failed to register dynamoDBMapperRef](https://github.com/boostchicken/spring-data-dynamodb/issues/25)
9+
3. [Limit and Consistent Reads only works on GSIs](https://github.com/boostchicken/spring-data-dynamodb/issues/23)
10+
11+
## New Features
12+
1. [Ability to apply filter expressions to a Query](https://github.com/boostchicken/spring-data-dynamodb/issues/27)
13+
14+
With static parameters
15+
```
16+
@Query(fields = "leaveDate", limit = 1, filterExpression = "contains(#field, :value)",
17+
expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")},
18+
expressionMappingValues = {@ExpressionAttribute(key=":value", value = "projection")})
19+
List<User> findByPostCode(String postCode);
20+
```
21+
22+
With dynamic parameters from methods
23+
```
24+
@Query(fields = "leaveDate", limit = 1, filterExpression = "contains(#field, :value)",
25+
expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")},
26+
expressionMappingValues = {@ExpressionAttribute(key=":value", parameterName = "projection")})
27+
List<User> findByPostCode(@Param("postCode") String postCode, @Param("projection") String projection);
28+
```
29+
2. [Support for Nested Repositories](https://github.com/boostchicken/spring-data-dynamodb/pull/24)
30+
```
31+
@EnableDynamoDBRepositories(basePackages = "org.socialsignin.spring.data.dynamodb.domain.sample", considerNestedRepositories = true)
32+
```

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Download the JAR though [Maven Central](http://mvnrepository.com/artifact/io.git
3434
<dependency>
3535
<groupId>io.github.boostchicken</groupId>
3636
<artifactId>spring-data-dynamodb</artifactId>
37-
<version>5.2.3</version>
37+
<version>5.2.4</version>
3838
</dependency>
3939
```
4040

@@ -167,12 +167,12 @@ API changes will follow SEMVER and loosly the Spring Framework releases.
167167
| 4.5.x | >= 1.4.0 && < 2.0 | >= 4.3 && < 5.0 | Ingalls |
168168
| 5.0.x | >= 2.0 && < 2.1 | >= 5.0 && < 5.1 | Kay-SR1 |
169169
| 5.1.x | == 2.1 | >= 5.1 | Lovelace-SR1 |
170-
| 5.2.x | >= 2.2 | >= 5.2 | Moore-RELEASE |
170+
| 5.2.x | >= 2.2 | >= 5.2 | Moore-RELEASE, Nuemann-RELASE |
171171

172172

173173
`spring-data-dynamodb` depends directly on `spring-data` as also `spring-context`, `spring-data` and `spring-tx`.
174174

175-
`compile` and `runtime` dependencies are kept to a minimum to allow easy integartion, for example into
175+
`compile` and `runtime` dependencies are kept to a minimum to allow easy integration, for example into
176176
Spring-Boot projects.
177177

178178
## History

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<modelVersion>4.0.0</modelVersion>
2121
<groupId>io.github.boostchicken</groupId>
2222
<artifactId>spring-data-dynamodb</artifactId>
23-
<version>5.2.4-SNAPSHOT</version>
23+
<version>5.2.5-SNAPSHOT</version>
2424
<name>Spring Data DynamoDB</name>
2525
<inceptionYear>2018</inceptionYear>
2626

@@ -32,13 +32,13 @@
3232
<licenses>
3333
<license>
3434
<name>The Apache License, Version 2.0</name>
35-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
35+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
3636
</license>
3737
</licenses>
3838

3939
<properties>
40-
<spring.version>5.2.0.RELEASE</spring.version>
41-
<spring-data.version>2.2.2.RELEASE</spring-data.version>
40+
<spring.version>5.2.3.RELEASE</spring.version>
41+
<spring-data.version>2.3.0.RELEASE</spring-data.version>
4242

4343
<hibernate-validator.version>6.1.0.Final</hibernate-validator.version>
4444
<aws-java-sdk.version>1.11.664</aws-java-sdk.version>
@@ -501,7 +501,7 @@
501501
<repositories>
502502
<repository>
503503
<id>spring-libs-snapshot</id>
504-
<url>http://repo.springsource.org/libs-snapshot</url>
504+
<url>https://repo.springsource.org/libs-snapshot</url>
505505
</repository>
506506
<repository>
507507
<id>dynamodb-local-oregon</id>
@@ -513,7 +513,7 @@
513513
<pluginRepositories>
514514
<pluginRepository>
515515
<id>com.springsource.repository.bundles.release</id>
516-
<url>http://repository.springsource.com/maven/bundles/release</url>
516+
<url>https://repository.springsource.com/maven/bundles/release</url>
517517
<snapshots>
518518
<enabled>false</enabled>
519519
</snapshots>

src/changes/changes.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
<author>boostchicken</author>
2424
</properties>
2525
<body>
26+
<release version="5.2.4" description="Feature Release">
27+
<action dev="boostchicken" type="add" issue="29" date="2020-05-24">
28+
Added Filter Expression Support
29+
</action>
30+
<action dev="felixwimpyw" type="fix" issue="25" date="2020-05-24">
31+
Failed to register dynamoDBMapperRef
32+
</action>
33+
<action dev="majusko" type="fix" issue="19" date="2020-05-24">
34+
Missing Local index projection settings
35+
</action>
36+
<action dev="phaser4" type="add" issue="24" date="2020-05-24">
37+
Nested Repository Support
38+
</action>
39+
</release>
2640
<release version="5.2.3" description="Security Release">
2741
<action dev="boostchicken" type="fix" issue="10" date="2020-02-24">
2842
Update Hibernate Validator to fix CVE
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright © 2018 spring-data-dynamodb (https://github.com/boostchicken/spring-data-dynamodb)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.socialsignin.spring.data.dynamodb.repository;
17+
18+
public @interface ExpressionAttribute {
19+
String key() default "";
20+
String value() default "";
21+
String parameterName() default "";
22+
}

src/main/java/org/socialsignin/spring/data/dynamodb/repository/Query.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,58 @@
5757
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html">Read Consistency</a>
5858
* @see <a href=
5959
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.OptionalConfig.html">DynamoDBMapper Configuration</a>
60-
* @return ConistentReadMode to enforce on query
60+
* @return ConsistentReadMode to enforce on query
6161
*/
6262
ConsistentReadMode consistentReads() default ConsistentReadMode.DEFAULT;
63+
64+
/**
65+
* Set filter expressions for a query
66+
*
67+
* @see <a href=
68+
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression">Filter Expressions</a>
69+
* @see <a href=
70+
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html"> Expression Syntax</a>
71+
*
72+
*
73+
* Example: {@code @Query(filterExpression = "contains(#field, :value)",
74+
* expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")},
75+
* expressionMappingValues = {@ExpressionAttribute(key=":value", value = "John Doe")})}
76+
*
77+
* @return filter expression for query
78+
*/
79+
String filterExpression() default "";
80+
81+
/**
82+
* Set filter expressions for a query
83+
*
84+
* @see <a href=
85+
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression">Filter Expressions</a>
86+
* @see <a href=
87+
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html"> Expression Syntax</a>
88+
*
89+
*
90+
* Example: {@code @Query(filterExpression = "contains(#field, :value)",
91+
* expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")},
92+
* expressionMappingValues = {@ExpressionAttribute(key=":value", value = "John Doe")})}
93+
*
94+
* @return expression name mappings for query
95+
*/
96+
ExpressionAttribute[] expressionMappingNames() default @ExpressionAttribute;
97+
98+
/**
99+
* Set filter expressions for a query
100+
*
101+
* @see <a href=
102+
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression">Filter Expressions</a>
103+
* @see <a href=
104+
* "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html">Expression Syntax</a>
105+
*
106+
*
107+
* Example: {@code @Query(filterExpression = "contains(#field, :value)",
108+
* expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")},
109+
* expressionMappingValues = {@ExpressionAttribute(key=":value", value = "John Doe")})}
110+
*
111+
* @return expression value mappings for query
112+
*/
113+
ExpressionAttribute[] expressionMappingValues() default @ExpressionAttribute;
63114
}

src/main/java/org/socialsignin/spring/data/dynamodb/repository/QueryConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ public enum ConsistentReadMode {
4747
*/
4848
EVENTUAL
4949
}
50+
5051
}

src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBRepositoryConfigExtension.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfi
9393
String repositoryBeanName = config.generateBeanName(builder.getBeanDefinition());
9494

9595
postProcess(builder, repositoryBeanName, attributes.getString("amazonDynamoDBRef"),
96-
attributes.getString("dynamoDBMapperConfigRef"), attributes.getString("dynamoDBOperationsRef"),
97-
attributes.getString("mappingContextRef"));
96+
attributes.getString("dynamoDBMapperRef"), attributes.getString("dynamoDBMapperConfigRef"),
97+
attributes.getString("dynamoDBOperationsRef"), attributes.getString("mappingContextRef"));
9898
}
9999

100100
/*
@@ -129,7 +129,8 @@ public void postProcess(BeanDefinitionBuilder builder, XmlRepositoryConfiguratio
129129

130130
private Map<String, String> dynamoDBTemplateCache = new HashMap<>();
131131
private void postProcess(BeanDefinitionBuilder builder, String repositoryName, String amazonDynamoDBRef,
132-
String dynamoDBMapperConfigRef, String dynamoDBOperationsRef, String dynamoDBMappingContextRef) {
132+
String dynamoDBMapperRef, String dynamoDBMapperConfigRef, String dynamoDBOperationsRef,
133+
String dynamoDBMappingContextRef) {
133134

134135
if (StringUtils.hasText(dynamoDBOperationsRef)) {
135136
builder.addPropertyReference("dynamoDBOperations", dynamoDBOperationsRef);
@@ -155,7 +156,12 @@ private void postProcess(BeanDefinitionBuilder builder, String repositoryName, S
155156
// AmazonDynamoDB amazonDynamoDB, DynamoDBMapper dynamoDBMapper,
156157
// DynamoDBMapperConfig dynamoDBMapperConfig
157158
dynamoDBTemplateBuilder.addConstructorArgReference(dynamoDBRef);
158-
dynamoDBTemplateBuilder.addConstructorArgReference(this.dynamoDBMapperName);
159+
160+
if (StringUtils.hasText(dynamoDBMapperRef)) {
161+
dynamoDBTemplateBuilder.addConstructorArgReference(dynamoDBMapperRef);
162+
} else {
163+
dynamoDBTemplateBuilder.addConstructorArgReference(this.dynamoDBMapperName);
164+
}
159165

160166
if (StringUtils.hasText(dynamoDBMapperConfigRef)) {
161167
dynamoDBTemplateBuilder.addConstructorArgReference(dynamoDBMapperConfigRef);

src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/EnableDynamoDBRepositories.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,10 @@
180180
* bean name
181181
*/
182182
String mappingContextRef() default "";
183+
184+
/**
185+
* Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the
186+
* repositories infrastructure.
187+
*/
188+
boolean considerNestedRepositories() default false;
183189
}

src/main/java/org/socialsignin/spring/data/dynamodb/repository/query/AbstractDynamoDBQuery.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ protected QueryExecution<T, ID> getExecution() {
7777
protected abstract Integer getResultsRestrictionIfApplicable();
7878
protected abstract boolean isSingleEntityResultsRestriction();
7979

80-
protected Query<T> doCreateQueryWithPermissions(Object values[]) {
80+
protected Query<T> doCreateQueryWithPermissions(Object[] values) {
8181
Query<T> query = doCreateQuery(values);
8282
query.setScanEnabled(method.isScanEnabled());
8383
return query;
8484
}
8585

86-
protected Query<Long> doCreateCountQueryWithPermissions(Object values[], boolean pageQuery) {
86+
protected Query<Long> doCreateCountQueryWithPermissions(Object[] values, boolean pageQuery) {
8787
Query<Long> query = doCreateCountQuery(values, pageQuery);
8888
query.setScanCountEnabled(method.isScanCountEnabled());
8989
return query;
@@ -244,13 +244,13 @@ private Slice<T> createSlice(List<T> allResults, Pageable pageable) {
244244
if (pageable.getOffset() > 0) {
245245
long processedCount = scanThroughResults(iterator, pageable.getOffset());
246246
if (processedCount < pageable.getOffset())
247-
return new SliceImpl<>(new ArrayList<T>());
247+
return new SliceImpl<>(new ArrayList<>());
248248
}
249249
List<T> results = readPageOfResultsRestrictMaxResultsIfNecessary(iterator, pageable.getPageSize());
250250
// Scan ahead to retrieve the next page count
251251
boolean hasMoreResults = scanThroughResults(iterator, 1) > 0;
252252
if (getResultsRestrictionIfApplicable() != null
253-
&& getResultsRestrictionIfApplicable().intValue() <= results.size())
253+
&& getResultsRestrictionIfApplicable() <= results.size())
254254
hasMoreResults = false;
255255
return new SliceImpl<>(results, pageable, hasMoreResults);
256256
}

0 commit comments

Comments
 (0)