Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Enhanced DynamoDb] List<CustomObject> is supported but not Set<CustomObject>? #5128

austinegri started this conversation in General
Discussion options

I found that a List for the DynamoDb enhanced client following works, but Set does not:

DynamoDbImmutable(builder = DdbObj.DdbObjBuilder.class)
public class DdbObj {
 @DynamoDbPartitionKey
 private final Integer id;
 private final List<CustomObject> objects;
DynamoDbImmutable(builder = CustomObject.CustomObjectBuilder.class)
public class CustomObject {
 private final Integer value;
TableSchema tableSchema = TableSchema.fromImmutableClass(DdbObj.class);

But the following does not:

DynamoDbImmutable(builder = DdbObj.DdbObjBuilder.class)
public class DdbObj {
 @DynamoDbPartitionKey
 private final Integer id;
 private final Set<CustomObject> objects;
TableSchema tableSchema = TableSchema.fromImmutableClass(DdbObj.class);

I get the error "IllegalStateException Converter not found for CustomObject"

After much time looking into the technical reason why this was it appears the root cause is that DDB Set attributes must be one of the following types: N, S, B see code.

If not for the above Set paramaterized type restriction to ImmutableTableSchema.java, It appears support for conversion for Set custom objects by adding the following:

 if (List.class.equals(rawType)) {
 EnhancedType<?> enhancedType = convertTypeToEnhancedType(parameterizedType.getActualTypeArguments()[0],
 metaTableSchemaCache, attributeConfiguration);
 return EnhancedType.listOf(enhancedType);
 }
 // *************** New Code Here ****************************
 if (Set.class.equals(rawType)) {
 EnhancedType<?> enhancedType = convertTypeToEnhancedType(parameterizedType.getActualTypeArguments()[0],
 metaTableSchemaCache, attributeConfiguration);
 return EnhancedType.setOf(enhancedType);
 }
 // *************** New Code Ends Here ****************************
 if (Map.class.equals(rawType)) {
 EnhancedType<?> enhancedType = convertTypeToEnhancedType(parameterizedType.getActualTypeArguments()[1],
 metaTableSchemaCache, attributeConfiguration);
 return EnhancedType.mapOf(EnhancedType.of(parameterizedType.getActualTypeArguments()[0]),
 enhancedType);
 }

Note: did past search could not find info on set of custom objects. See similar 1, 2

My question is why can Set type not support collections of custom objects if they can be supported for Lists? Can we remove the Set type restriction and add the above changes to support Set?

You must be logged in to vote

Replies: 1 comment

Comment options

I checked this and got the same... If I translate all my Set's to List's, it's fine...

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /