【发布时间】:2019-03-13 20:25:16
【问题描述】:
我遵循了此处概述的所有内容 - https://github.com/derjust/spring-data-dynamodb/wiki/Use-Hash-Range-keys。但仍然没有运气。
我有一个带有哈希键和排序键的 DynamoDB 表。
这是我的实体类RecentlyPlayed.class
@DynamoDBTable(tableName="some-table")
public class RecentlyPlayed {
@Id
private RecentlyPlayedId recentlyPlayedId;
// ----- Constructor methods -----
@DynamoDBHashKey(attributeName="keyA")
// Getter and setter
@DynamoDBRangeKey(attributeName="keyB")
// Getter and setter
}
这是我的关键课程RecentlyPlayedId.class
public class RecentlyPlayedId implements Serializable {
private static final long serialVersionUID = 1L;
private String keyA;
private String keyB;
public RecentlyPlayedId(String keyA, String keyB) {
this.keyA = keyA;
this.keyB = keyB;
}
@DynamoDBHashKey
// Getter and setter
@DynamoDBRangeKey
// Getter and setter
}
这是我的仓库界面RecentlyPlayedRepository
@EnableScan
public interface RecentlyPlayedRepository extends CrudRepository<RecentlyPlayed, RecentlyPlayedId> {
List<RecentlyPlayed> findAllByKeyA(@Param("keyA") String keyA);
// Finding the entry for keyA with highest keyB
RecentlyPlayed findTop1ByKeyAOrderByKeyBDesc(@Param("keyA") String keyA);
}
我正在尝试保存这样的对象
RecentlyPlayed rp = new RecentlyPlayed(...);
dynamoDBMapper.save(rp); // Throws that error
recentlyPlayedRepository.save(rp); // Also throws the same error
我正在使用Spring v2.0.1.RELEASE。原始文档中的 wiki 警告此错误并描述了如何缓解。我完全按照他们说的做了。但仍然没有运气。
该 wiki 的链接在这里 - https://github.com/derjust/spring-data-dynamodb/wiki/Use-Hash-Range-keys
【问题讨论】:
-
非常透明地描述了您的路径。但是可以将抛出的指示异常添加为堆栈跟踪。
标签: java spring-boot spring-data-jpa amazon-dynamodb