I am using PostgreSQL. In that I created a function. I want to call that function into service method.I created repository for that function using native query. But I am unable to get the result which I get when running the function in PostgreSQL db. I get exception like "No converter found capable of converting from type [java.math.BigDecimal] to type [com.spacestudy.model.DeptListForJointusePer]".
Model:
@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
Repository:
@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);
Service:
public List<DeptListForJointusePer> getDeptListForViewModifyJoinyusePer(Integer p_nInstID,Integer p_nDeptID) {
List<DeptListForJointusePer> result = roomDeptMapRepoObj.getDeptListForViewModifyJointUsePercentages(p_nInstID, p_nDeptID);
return result;
}
Controller:
@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);
}
error:
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]