-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dyanmodb Enchanced client nested Objects as json #2265
Comments
I'm wondering why this should not work. I stumbled upon a problem with nested Java classes, but the exception was triggered by a different problem. Did you add |
I am using StaticTableSchema builder to reduce startup time, so no annotations. One work around would be to create custom attribute converter, but thats tedious. If i don't provide attribute converter, i get exception
java.lang.ExceptionInInitializerError |
@catchin @scmacdon @beckandros @bmaizels Would you know how to define Static table schema for structure in original post. |
Ok got this to working In the custom converter i had to make sure there was no empty attribute, of lots of null checks.
Is there a way when defining static table schema to avoid defining custom converters for nested documents? |
@tkindra2 There are two ways to do this without having to create a custom converter:
|
@bmaizels Thanks! I like the first option to minimize cold start, but
The return type of Customer::getRecordMetadata is List not GenericRecord so i get compilation error. How do we fix this? |
@tkindra2 |
@bmaizels Thanks! that worked! Also i have nested documents, example if Generic record had another list of documentX, how would that be defined? does TableSchema.fromClass scan nested @DynamoDbBean? |
When you are creating the TableSchema of genericRecord, just do it the same way, use an EnhancedType.documentOf for the attribute definition.
Yes, although defining a StaticTableSchema directly does not. So if you want to use nested annotated classes you have to use an annotation scanner on the parent class. I didn't think you wanted to do annotation scanning, so I focused on giving you the direct static examples using EnhancedType. |
@bmaizels Thanks! I spent several hours getting this right. Could this be added as one of the examples. Thank you again |
Can you do a Pull Request against our Github repo here please:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/dynamodb
Thxs
From: tkindra2 <notifications@github.com>
Sent: Monday, February 8, 2021 5:16 PM
To: aws/aws-sdk-java-v2 <aws-sdk-java-v2@noreply.github.com>
Cc: Macdonald, Scott <scmacdon@amazon.com>; Mention <mention@noreply.github.com>
Subject: Re: [aws/aws-sdk-java-v2] Dyanmodb Enchanced client nested Objects as json (#2265)
@bmaizels<https://github.com/bmaizels> Thanks! I spent several hours getting this right. Could this be added as one of the examples.
Thank you again
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#2265 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANUKOT4NXAF4BJ6ONQPCIBTS6BPCLANCNFSM4WZQZJLQ>.
|
I added Same case as above. ParentClass with the annotation, has a list of items by ChildClass (has the annotation too) |
@tkindra2 thank you for the feedback, I agree that we should have more examples about this case, marking as a documentation issue. @kevcodez I saw your comment in #2277 (comment), let's track this issue over there. Please provide a minimal working code we can use to reproduce the issue. |
@scmacdon Can you please confirm if the example for having nested documents, with nested one being a list, has been added to the repo? It would be great to have one though |
The second is the best way to do that. |
I have nested Object (composition) use to represent data that i want to store and using Dyanmodb enhanced client as part of AWS Java version 2 api. In the readme it explains how to flatten the objects. In the version one of the api was able to store list of objects as json documents in dyanmodb. Would like it to be stored as Json not flattened for backward compatibility:
Steps to Reproduce
Would like it to be stored as below not flattened for backward compatibility:
Current Behavior
In the readme it only describe how to flatten
https://github.com/aws/aws-sdk-java-v2/blob/master/services-custom/dynamodb-enhanced/README.md
Your Environment
The text was updated successfully, but these errors were encountered: