简体   繁体   中英

java.lang.Long cannot be cast to java.math.BigDecimal

Db table information:

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

DAO class:

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;
    }
}

Result:

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

您没有提供足够的问题详细信息,但显然它应该转换为BigDecimal

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM