java - Is using DynamoDBMapper a bad idea? -


i've started on dynamodb , came across instruction on dynamodbmapper http://aws.amazon.com/articles/0802321832592496

let have user pojo, dynamodb annotations added like:

@dynamodbtable(tablename = "users") public class user {      private integer id;     private set<string> friends;     private string status;      @dynamodbhashkey     public integer getid() { return id; }     public void setid(integer id) { this.id = id; }      @dynamodbattribute     public set<string> getfriends() { return friends; }     public void setfriends(set<string> friends) { this.friends = friends; }      @dynamodbattribute     public string getstatus() { return status; }     public void setstatus(string status) { this.status = status; } } 

since pojo used carry data across layers in typical application, e.g persistence layer api layer ... sound bad idea tie specific database technology.

in relational realm, 1 use java persistence api annotation, database agnostic. dynamodb, it's not case. , in case database changed in future, need modify pojo class. not sound practice.

so should dynamodbmapper used, or should use lower level api?

jpa aims database agnostic, has migrated real application 1 database can tell doesn't handle of edge cases.

while point dynamodb annotations specific dynamodb valid, afford benefits in keeps application logic persistence agnostic. example, not using annotations have work dynamodb objects map<string, object> throughout application. using mapper, can instead work items stored in dynamodb user objects , business logic can performed on user objects.

now let's need switch store users in different database...mongodb or relational db whatever reason. yes, you'd have change annotations on user object works new persistence store requires (just you'd have modify of them if using jpa switched mysql postgres), application logic, i.e business rules , validation on user objects throughout application, not have change.

so, while have use dynamodb annotations use mapper, benefits gain being able implement application logic directly on domain entities far outweigh concerns on coupling persistence solution, , mirror benefits of jpa more closely assert, in opinion.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -