You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/org/socialsignin/spring/data/dynamodb/repository/support/DynamoDBHashAndRangeKeyMethodExtractorImpl.java
+23-12Lines changed: 23 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -37,10 +37,10 @@ public class DynamoDBHashAndRangeKeyMethodExtractorImpl<T> implements DynamoDBHa
37
37
38
38
privateFieldhashKeyField;
39
39
privateFieldrangeKeyField;
40
-
40
+
41
41
/**
42
42
* Creates a new {@link DefaultJpaEntityMetadata} for the given domain type.
43
-
*
43
+
*
44
44
* @param domainType
45
45
* must not be {@literal null}.
46
46
*/
@@ -49,7 +49,8 @@ public DynamoDBHashAndRangeKeyMethodExtractorImpl(final Class<T> idType) {
49
49
Assert.notNull(idType, "Id type must not be null!");
if (field.getAnnotation(DynamoDBRangeKey.class) != null) {
85
89
Assert.isNull(rangeKeyMethod,
86
90
"Multiple methods annotated by @DynamoDBRangeKey within type " + idType.getName() + "!");
@@ -89,11 +93,18 @@ public void doWith(Field field) {
89
93
}
90
94
}
91
95
});
92
-
Assert.isTrue(hashKeyMethod != null || hashKeyField != null, "No method or field annotated by @DynamoDBHashKey within type " + idType.getName() + "!");
93
-
Assert.isTrue(rangeKeyMethod != null || hashKeyField != null, "No method or field annotated by @DynamoDBRangeKey within type " + idType.getName() + "!");
94
-
Assert.isTrue(hashKeyMethod == null || hashKeyField == null, "Both method and field annotated by @DynamoDBHashKey within type " + idType.getName() + "!");
95
-
Assert.isTrue(rangeKeyMethod == null || hashKeyField == null, "Both method and field annotated by @DynamoDBRangeKey within type " + idType.getName() + "!");
96
-
96
+
if (hashKeyMethod == null && hashKeyField == null) {
97
+
thrownewIllegalArgumentException("No method or field annotated by @DynamoDBHashKey within type " + idType.getName() + "!");
98
+
}
99
+
if (rangeKeyMethod == null && hashKeyField == null) {
100
+
thrownewIllegalArgumentException("No method or field annotated by @DynamoDBRangeKey within type " + idType.getName() + "!");
101
+
}
102
+
if (hashKeyMethod != null && hashKeyField != null) {
103
+
thrownewIllegalArgumentException("Both method and field annotated by @DynamoDBHashKey within type " + idType.getName() + "!");
0 commit comments