2017-09-13 94 views
0

我有一個實體類,它有一些字符串/ ints作爲成員變量和類型爲Photo的成員變量。我已經定義圖片類型爲:Dynamodb映射器在使用@DBDocument註釋時無法讀取

@DynamoDBDocument 
public static class Photo { 
    @DynamoDBAttribute(attributeName = "url") 
    public String getUrl() { 
     return url; 
    } 

    @DynamoDBAttribute(attributeName = "width") 
    public Integer getWidth() { 
     return width; 
    } 

    @DynamoDBAttribute(attributeName = "height") 
    public Integer getHeight() { 
     return height; 
    } 

    public void setUrl(String url) { 
     this.url = url; 
    } 

    public void setWidth(Integer width) { 
     this.width = width; 
    } 

    public void setHeight(Integer height) { 
     this.height = height; 
    } 

    private String url; 
    private Integer width; 
    private Integer height; 

    public Photo(String url, Integer width, Integer height) { 
     this.url = url; 
     this.width = width; 
     this.height = height; 
    } 
} 

當我嘗試寫一個實體對象,我可以看到圖片類型被存儲爲映射(M)。

但是當我嘗試從發電機讀取相同的實體,它提供例外:

com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: PostingPhotoEntity[detail]; could not unconvert attribute 

如果非要定義照片轉換/ unconvert,那又有什麼用@DBDocument註解。我曾認爲它也可以反序列化表中的數據。

請幫忙!

回答

0

我必須定義一個默認的構造函數用於照片

public Photo() { }