java.lang.Long无法强制转换为java.math.BigDecimal

时间:2014-04-08 10:37:28

标签: java hibernate casting long-integer bigdecimal

Db表信息:

fid [NUMBER(32,0)PK]
status [VARCHAR2(10)]

DAO课程:

public Integer Update_bank_dep(Long fid, String status) {
    try {
        String query       = "update WtrBnkdep as wb set wb.wtrbdStus=:status where wb.wtrbdUniqval=:fid";
        Query  queryobject = get_session().createQuery(query);

        queryobject.setParameter("fid", fid);
        queryobject.setParameter("status", status); 
        int cd = queryobject.executeUpdate();
        System.out.println("cd=" + cd);

        return cd;
    } catch(RuntimeException ex) {
        System.out.println("Error="+ex);
        throw ex;
    }
}

结果:

Error=java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigDecimal

1 个答案:

答案 0 :(得分:2)

您尚未提供足够的问题详细信息,但显然应将其转换为BigDecimal

queryobject.setParameter("fid", new BigDecimal(fid));