首页 > 解决方案 > 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]

标签: postgresqlspring-data-jpa

解决方案


推荐阅读