DynamoDb error: converter not found for EnhancedType(java.util.Optional)

See original GitHub issue

Describe the issue

I’m trying to write to DynamoDb my object model with an Optional field, but it does not work. If I exclude the Optional field from my model I can successfully save it to DynamoDb.

Steps to Reproduce

private final String notificationText;

public Optional<String> getNotificationText() {
    return Optional.ofNullable(notificationText);
}

public void setNotificationText(Optional<String> notificationText) {
    // Do nothing, this is a derived attribute
}

Current behavior

I’m obtaining this error: java.lang.IllegalStateException: Converter not found for EnhancedType(java.util.Optional)

I’m trying to create my custom ConvertProvider implementing AttributeConverterProvider and using the OptionalAttributeConverter but I don’t understand how to use it. Can someone help me?

AWS Java SDK version used

dynamodb-enhanced version 2.17.102

JDK version used

openjdk version “1.8.0_312”

Operating System and version

Linux 5.4.0-91-generic #102-Ubuntu

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marcogramycommented, Dec 30, 2021

Following your advices I’ve created a CustomAttributeConverterProvider with OptionalAttributeConverter<String> and now it works! I’ve updated my demo project for any future references: https://github.com/marcogramy/dynamodbdemo

Thank you for your help!

0reactions
github-actions[bot]commented, Dec 30, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enhanced Dynamodb not support List<CustomObject> type?
In my table schema there is List property,try to save the object,got following error Converter not found for EnhancedType(java.util.
Read more >
Dynamodb attribute converter provider for enhanced type ...
I have a type which is extending HashMap<String, String> . As per the documentation here, it is possible to add a custom converter...
Read more >
DynamoDB Enhanced Client for Java: Missing Setters Cause ...
The AWS SDK v2 for Java's DynamoDB Enhanced Client requires setters for every attribute. Missing the setter for a given attribute may cause ......
Read more >
Mapping arbitrary data - Amazon DynamoDB
Map arbitrary data to the Amazon DynamoDB types using the DynamoDBMapper class of the AWS SDK for Java.
Read more >
How to use Enhanced DynamoDB AWS sdk for Java v2 in ...
In this post you will see how to make use of this new sdk in a spring boot application to save data in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found