Skip to content

Commit 4d9580c

Browse files
Michael Wolfederjust
authored andcommitted
Checking both method and fields for a DynamoDBMarshaller annotation
First checks for a method with the given property name and annotation and if not found then checks for a field with the given property name and annotation.
1 parent 4d018aa commit 4d9580c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/org/socialsignin/spring/data/dynamodb/repository/support/DynamoDBEntityMetadataSupport.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,23 @@ public String getOverriddenAttributeName(final String propertyName) {
286286

287287
@Override
288288
public DynamoDBMarshaller<?> getMarshallerForProperty(final String propertyName) {
289+
DynamoDBMarshalling annotation = null;
289290

290291
Method method = findMethod(propertyName);
291-
if (method != null && method.getAnnotation(DynamoDBMarshalling.class) != null) {
292+
if (method != null) {
293+
annotation = method.getAnnotation(DynamoDBMarshalling.class);
294+
}
295+
296+
if(annotation == null) {
297+
Field field = findField(propertyName);
298+
if(field != null) {
299+
annotation = field.getAnnotation(DynamoDBMarshalling.class);
300+
}
301+
}
302+
303+
if(annotation != null) {
292304
try {
293-
return method.getAnnotation(DynamoDBMarshalling.class).marshallerClass().newInstance();
305+
return annotation.marshallerClass().newInstance();
294306
} catch (InstantiationException e) {
295307
throw new RuntimeException(e);
296308
} catch (IllegalAccessException e) {

0 commit comments

Comments
 (0)