java - 如何使用外键类型从 jpa 存储库返回选择查询
问题描述
我正在尝试这样做:
@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]
解决方案
您的请求告诉您想要一个 BigInteger 列表: SELECT DISTINCT comarca_id... 因为我猜comarca_id 是一个 biginteger。如果你想要一份 Comarca 名单,你必须在你的所有桌子上提出要求。
推荐阅读
- arrays - 计算符合条件的行,忽略具有相同非唯一值的行(即在特定国家/地区的特定日期之前的所有奖励)
- assembly - 如何在 16 位汇编中将 320x200 像素映射到 VGA 视频内存
- react-native - 函数 clearInterval() 不起作用 React Native
- php - 捕获所有 PHP 异常是最佳实践吗?
- postgresql - Servicestack ORMLite - 在 PostgreSQL 中使用 XML 字段
- regex - Apache 重定向 URI 请求
- opengl-es - 在 OpenGL 中执行每个片段的 DEPTH_TEST
- spring-boot - 使用事务会话时,使用 Artemis 和 Spring JMS 进行消息分组不起作用
- python - 使用 Pandas 通过唯一索引过滤大型数据帧
- asp.net-core - 在 asp.net core F# 中未发现控制器