我的域模型是这样的:
CollectedData {
String name;
String description;
int count;
int xAxis,
int yAxis
}
使用 Spring 数据存储库查询,我想检索所有唯一的行(唯一的名称、xAxis、yAxis)
我正在尝试这样的事情
@Query("select distinct a.name, a.xAxis, a.yAxis from CollectedData a")
List<CollectedData> findAllDistinctData();
所以,当我这样做时
List<CollectedData> records= findAllDistinctData();
for (CollectedData record : records) { //Exception on this line
}
异常 [Ljava.lang.Object; 不能强制转换为 CollectedData。
有没有其他方法可以为此编写查询?