Skip to content

Dynamo DB Polymorphism (Feedback Requested) #1229

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

Closed
wants to merge 1 commit into from

Conversation

kiiadi
Copy link
Contributor

@kiiadi kiiadi commented Jul 12, 2017

In response to issue #832, this introduces a new @DynamoDBSubTyped annotation to describe known sub-types of a class along with a string-identifier for those types that is persisted to the Dynamo table and allows the sub-type information to be persisted at save and retrieved at load time.

Example usage:

@DynamoDBSubTyped({
	@SubType(name = "firstSubType", value = FirstSubType.class),
	@SubType(name = "secondSubType", value = SecondSubType.class)
})
class BaseClass { }

class FirstSubType extends BaseClass { }
class SecondSubType extends BaseClass { }

By default the type name is stored in a String field in Dynamo called "_type"; this can be customized by providing the "attributeName" property to the @DynamoDBSubTyped annotation. This attribute can refer to an property already on the object or if it doesn't exist as a property of the object it will be created in the dynamo db table. It must be of type java.lang.String.

The above example allows the following:

mapper.save(firstSubType);
mapper.save(secondSubType);

FirstSubType loadedFirstSubType = (FirstSubType) mapper.load(BaseClass.class, /*some id for firstSubType*/);

Also works with when scanning/querying:

List<BaseClass> objects = mapper.scan(BaseClass.class);
objects.forEach(o -> System.out.println(o.getClass())); 
/* prints FirstSubType.class, SecondSubType.class */

@pradeeptk304
Copy link

This is a useful feature, usage is also simple. When will this be merged?

@pluttrell
Copy link

@kiiadi Any update on when this might get merged and then released?

@pipoescomo
Copy link

Please merge.

@jeansossmeier
Copy link

jeansossmeier commented Jun 5, 2018

+1

9 similar comments
@siwonred
Copy link

+1

@avernonquantify
Copy link

+1

@junbong
Copy link

junbong commented Aug 31, 2018

+1

@khayashi4337
Copy link

+1

@alexandredavi
Copy link

+1

@ojh3636
Copy link

ojh3636 commented Jun 26, 2019

+1

@billopark
Copy link

+1

@shimika
Copy link

shimika commented Jun 27, 2019

+1

@ghost
Copy link

ghost commented Jun 27, 2019

+1

@woldieJDI
Copy link

THE POWER OF THE SWOOSH COMPELS YOU TO MERGE!

@showmeyourcode
Copy link

+1

1 similar comment
@sahlouls
Copy link

sahlouls commented Oct 2, 2019

+1

@jackyjjc-canva
Copy link

Any update on when does this PR gets merge? @kiiadi

@gakinson
Copy link

gakinson commented Dec 3, 2019

Follow up on completion of this feature?

@dleffel
Copy link

dleffel commented Jan 15, 2020

Is this set to merge or is there any other problems?

@pan-con-jamon
Copy link

Hi! Any reason why this hasn't been merged already? It's the only lacking feature I need for my DynamoDB project

@adrG2
Copy link

adrG2 commented Feb 14, 2020

Any update?

@millems
Copy link
Contributor

millems commented Jun 2, 2020

Unfortunately this pull request doesn't have enough tests (either functional or performance) for the Java SDK team to merge as-is, and we haven't prioritized doing that testing, since a lot of people are very vocal about wanting us to focus on V2 of the SDK.

I've created a feature request for adding this feature to the V2 DynamoDB enhanced client: aws/aws-sdk-java-v2#1870. We're currently leaning towards just doing this with the enhanced client in V2, since that's much better tested and understood.

@debora-ito
Copy link
Member

debora-ito commented May 9, 2023

Closing this PR, we don't have plans to merge this DynamoDB Mapper feature at this point.

@debora-ito debora-ito closed this May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.