Database Reference
In-Depth Information
Java high-level API
For those who have an idea about Java Database Connectivity ( JDBC ) and Java Persist-
ence API ( JPA ), DynamoDB's Java low-level API is like JDBC and DynamoDB's Java
high-level API is like JPA, which allows us to map a DynamoDB table with a Java class.
Therefore, setting the values to the instance variable is like adding attributes to the item.
This is what we call object-relational mapping ( ORM ). But in DynamoDB, we call this
by a different name, and that is object persistence model.
In a high-level API, a Java class is directly mapped to a DynamoDB table, because of
which a large amount of redundant code and conditions can be avoided. Another advantage
with this API is that it comes with a few methods, such as save, load, and delete, which are
thread safe and allow us to enact locking techniques.
Now, let's create a class to be mapped to the Tbl_Book table in DynamoDB.
@DynamoDBTable(tableName="Tbl_Book")
public class BookEntity {
private String BookTitle;
private String Author;
private String PubDate;
private String Publisher;
private Integer Edition;
private Set<String> Language;
@DynamoDBHashKey(attributeName="BookTitle")
public String getBookTitle() {
return BookTitle;
}
public void setBookTitle(String bookTitle) {
BookTitle = bookTitle;
}
@DynamoDBAttribute(attributeName="Author")
public String getAuthor() {
return Author;
}
public void setAuthor(String author) {
Author = author;
}
@DynamoDBRangeKey(attributeName="PubDate")
Search WWH ::




Custom Search