【发布时间】:2021-10-31 03:27:48
【问题描述】:
我有一个看起来像这样的CrudRepository:
public interface MyDocumentRepository extends CrudRepository<MyDocument, String> {}
在我的对象 MyDocument 中,我有:
@DynamoDBTable(tableName = "MyDocument ")
public class MyDocument {
@DynamoDBHashKey
private String id;
@DynamoDBAttribute
private List<String> anotherIds;
...
}
我试图通过 id1 和 id2 获取所有可以包含 anotherId 的文档:
List<MyDocument> findAllByIdAndAnotherIdContains(String id, String anotherId);
但这对我不起作用,我收到此错误:
class java.lang.String cannot be cast to class java.util.List (java.lang.String and java.util.List are in module java.base of loader 'bootstrap')
我尝试了很多方法,但都返回此错误:
List<MyDocument> findAllByIdAndAnotherIdsContains(String id, List<String> anotherId);
List<MyDocument> findByIdAndAnotherIdsContains(String id, List<String> anotherId);
List<MyDocument> findByIdAndAnotherIdsContains(String id, String anotherId);
List<MyDocument> findByIdAndAnotherIdsContaining(String id, String anotherId);
List<MyDocument> findByIdAndAnotherIdsContaining(String id, List<String> anotherId);
知道如果没有@Query,我该怎么做吗?
【问题讨论】:
标签: java spring-boot spring-data-jpa amazon-dynamodb crud-repository