我正在尝试这样做:@Query(value = "SELECT DISTINCT c.* FROM comarca c INNER JOIN debito_negativacao d ON d.comarca_id = c.id WHERE d.status = :status", nativeQuery = true)List<Comarca> findDistinctComarcaByStatus(@Param("status") String status);但我得到这个错误: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type [com.hc.projects.model.Comarca] for value '{9, 0, 7323}'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.math.BigInteger] to type [com.hc.projects.model.Comarca]
3 回答
Qyouu
TA贡献1786条经验 获得超11个赞
如果第二次要隔离comarca_id 列表,请尝试流式传输您的请求结果。
List<Comarca> comarca = debitoNegativacao.stream().map(dn -> dn.getComarca()).distinct().collect(Collectors.toList());
++
Cats萌萌
TA贡献1805条经验 获得超9个赞
您必须返回构造 Comarca 所需的所有列。所以你必须加入表。
由于没有提供表格,我只能猜测:
@Query(value = "SELECT DISTINCT * FROM comarca c " +
"JOIN debito_negativacao d ON d.comarca_id = c.id "+
"WHERE d.debito_negativacao.status= :status", nativeQuery = true)
List<Comarca> findDistinctComarcaIdByStatus(@Param("status") String status);
浮云间
TA贡献1829条经验 获得超4个赞
您的请求告诉您想要一个 BigInteger 列表: SELECT DISTINCT comarca_id... 因为我猜comarca_id 是一个 biginteger。如果你想要一份 Comarca 名单,你必须在你的所有桌子上提出要求。
添加回答
举报
0/150
提交
取消
