java.lang.Long 不能转换为 java.math.BigDecimal
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22934467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 19:21:09 来源:igfitidea点击:
java.lang.Long cannot be cast to java.math.BigDecimal
提问by sathya
Db table information:
db表信息:
fid [NUMBER(32,0)PK]
status [VARCHAR2(10)]
DAO class:
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;
}
}
Result:
结果:
Error=java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigDecimal
回答by Konstantin Yovkov
You haven't provided enough details to the problem, but obviously it should be converted to BigDecimal
:
您没有提供足够的问题详细信息,但显然应该将其转换为BigDecimal
:
queryobject.setParameter("fid", new BigDecimal(fid));