postgresql - ConverterNotFoundException:从类型 [java.math.BigDecimal] 到类型 [com.spacestudy.model.DeptListForJointusePer]
问题描述
我正在使用 PostgreSQL。在那里我创建了一个函数。我想将该函数调用到服务方法中。我使用本机查询为该函数创建了存储库。但是我无法得到在 PostgreSQL 数据库中运行该函数时得到的结果。我收到异常,例如“找不到能够从类型 [java.math.BigDecimal] 转换为类型 [com.spacestudy.model.DeptListForJointusePer] 的转换器”。
模型:
@Entity
public class DeptListForJointusePer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column
public Integer p_nDeptID;
@Column
public Integer res_salaryPercent;
@Column
public Integer res_nClientCPCMappingId;
@Column
public String res_CPCCODE ;
@Column
public String res_sDeptName ;
@Column
public String res_sClientDeptId ;
@Column
@JsonProperty(value = "text")
public String res_sAlternateJointUsePercentage;
//getters and setters
存储库:
@Query(nativeQuery = true, value = "SELECT * from GetDeptListForViewModifyJointUsePercentages(:p_nInstID,:p_nDeptID)")
List<DeptListForJointusePer> getDeptListForViewModifyJointUsePercentages(@Param("p_nInstID")Integer p_nInstID,@Param("p_nDeptID") Integer p_nDeptID);
服务:
public List<DeptListForJointusePer> getDeptListForViewModifyJoinyusePer(Integer p_nInstID,Integer p_nDeptID) {
List<DeptListForJointusePer> result = roomDeptMapRepoObj.getDeptListForViewModifyJointUsePercentages(p_nInstID, p_nDeptID);
return result;
}
控制器:
@GetMapping("/function")
public List<DeptListForJointusePer> function(@RequestParam(value="p_nInstID",required=true)Integer p_nInstID
,@RequestParam(value="p_nDeptID",required=true)Integer p_nDeptID){
return roomDeptMapServiceObj.getDeptListForViewModifyJoinyusePer(p_nInstID, p_nDeptID);
}
错误:
Failed to convert from type [java.lang.Object[]] to type [com.spacestudy.model.DeptListForJointusePer] for value '{21714, 12.50000000000000000000, 7, IDR, Electron Microscopy Resource Center, 111070, YES}';
nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.math.BigDecimal] to type [com.spacestudy.model.DeptListForJointusePer]
解决方案
推荐阅读
- php - 单击添加更多字段按钮后动态显示字段
- javascript - 使用 react 和 react-firebase-hooks 时的无限循环
- php - 发送 POST 请求以获取数据时 PHP cURL 不起作用
- python - 为什么我无法在我的 jupyter 笔记本上安装模块“nturl2path”?
- sql - 多个可为空的外键是一个糟糕的设计吗?
- javascript - JavaScript - 在没有用户干预的情况下停止重定向并获取目标 URL
- python - MinMaxScaler 仅生成正值
- mysql - MySQL 分区的预定截断
- rust - 如何在 Rust 中拒绝没有显式类型注释的 int 变量?
- authorization - Akka.Net:透明地传递上下文信息以进行审计/授权