Created
February 26, 2021 06:51
-
-
Save user20161119/f177d01b59941744f7b45f34b1082141 to your computer and use it in GitHub Desktop.
dynamodb java sdk collection type support,reference doc https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.DataTypes.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.aws.dynamodb; | |
import java.math.BigDecimal; | |
import java.time.Instant; | |
import java.util.ArrayList; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Set; | |
import lombok.ToString; | |
import lombok.experimental.Accessors; | |
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean; | |
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey; | |
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbSecondaryPartitionKey; | |
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbSecondarySortKey; | |
@DynamoDbBean | |
@Accessors(chain = true) | |
@ToString | |
public class Order { | |
private Long id; | |
private Long cusId; | |
private Long orderTime; | |
private BigDecimal orderAmt; | |
private Instant shipTime; | |
private OrderStatus orderStatus; | |
//Set not support custom java object,i.e OrderItem | |
private Set<String> orderItemSet = new HashSet<>(); | |
private List<OrderItem> itemList = new ArrayList<>(); | |
private List<Map<String, OrderItem>> mapList = new ArrayList<>(); | |
@DynamoDbPartitionKey | |
public Long getId() { | |
return id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
@DynamoDbSecondaryPartitionKey(indexNames = "cusid_ordertime") | |
public Long getCusId() { | |
return cusId; | |
} | |
public void setCusId(Long cusId) { | |
this.cusId = cusId; | |
} | |
@DynamoDbSecondarySortKey(indexNames = "cusid_ordertime") | |
public Long getOrderTime() { | |
return orderTime; | |
} | |
public void setOrderTime(Long orderTime) { | |
this.orderTime = orderTime; | |
} | |
public BigDecimal getOrderAmt() { | |
return orderAmt; | |
} | |
public void setOrderAmt(BigDecimal orderAmt) { | |
this.orderAmt = orderAmt; | |
} | |
public Instant getShipTime() { | |
return shipTime; | |
} | |
public void setShipTime(Instant shipTime) { | |
this.shipTime = shipTime; | |
} | |
public Set<String> getOrderItemSet() { | |
return orderItemSet; | |
} | |
public void setOrderItemSet(Set<String> orderItemSet) { | |
this.orderItemSet = orderItemSet; | |
} | |
public OrderStatus getOrderStatus() { | |
return orderStatus; | |
} | |
public void setOrderStatus(OrderStatus orderStatus) { | |
this.orderStatus = orderStatus; | |
} | |
public List<OrderItem> getItemList() { | |
return itemList; | |
} | |
public void setItemList(List<OrderItem> itemList) { | |
this.itemList = itemList; | |
} | |
public List<Map<String, OrderItem>> getMapList() { | |
return mapList; | |
} | |
public void setMapList(List<Map<String, OrderItem>> mapList) { | |
this.mapList = mapList; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.aws.dynamodb; | |
import java.math.BigDecimal; | |
import lombok.ToString; | |
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean; | |
@DynamoDbBean | |
@ToString | |
public class OrderItem { | |
private int qit; | |
private BigDecimal amt; | |
public int getQit() { | |
return qit; | |
} | |
public void setQit(int qit) { | |
this.qit = qit; | |
} | |
public BigDecimal getAmt() { | |
return amt; | |
} | |
public void setAmt(BigDecimal amt) { | |
this.amt = amt; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment