Java????????????????????
???????????? ???????[ 2011/11/30 10:58:21 ] ????????
?????????л???????????????????????????????????????????????????????????????£????????????????????????????????????????Щ????????????????????
?????б?????£?
T_SOME_TABLE{
crowid varchar(36);
zrmb float(7??3);
zjdw float(7??3);
}
?????????????δ?????λ????????????
??????????????
//??????????£?
String hqlStr="select SUM(t.zrmb) AS SUM_1??SUM(t.zjdw) AS SUM_2 from T_SOME_TABLE t where 1=1 ";
List sumList=baseDao.find(hqlStr);//hibernate?????HQL???????????List
request.setAttribute("sumList"??sumList);
//?????????£?
String sum1="";
String sum2="";
ArrayList sumList=request.getAttribute("sumList")==null?null:(ArrayList)request.getAttribute("sumList");
if(null!=sumList){
for(int i=0;i<sumList.size();i++){
Object[] tempObj=(Object[])sumList.get(i);
sum1=tempObj[0]==null?"0.0":tempObj[0].toString();
sum2=tempObj[1]==null?"0.0":tempObj[1].toString();
}
}
out.prinln("sum1:"+sum1);
out.prinln("sum2:"+sum2);
??????????ζ???
//??????????£?
String hqlStr="select SUM(t.zrmb) AS SUM_1 from T_SOME_TABLE t where 1=1 ";
List sumList=baseDao.find(hqlStr);//hibernate?????HQL???????????List
request.setAttribute("sumList"??sumList);
//?????????£?
String sum1="";
ArrayList sumList=request.getAttribute("sumList")==null?null:(ArrayList)request.getAttribute("sumList");
if(null!=sumList){
for(int i=0;i<sumList.size();i++){
Object[] tempObj=(Object[])sumList.get(i);
sum1=tempObj[0]==null?"0.0":tempObj[0].toString();
}
}
out.prinln("sum1:"+sum1);
??????????л??? ???????2???????? ?????????1?????????????е?????????????????????? ???2???????1???????????????????????????????? ???????????????????????????????????????????????????????????????????????????£?
????????hibernate???????? ??hibernate????sql??????????????????????????Object????浽List?е????????1?????2???????????????ε????????????2?????????? ?????????Object[]???????????????飬??????????????ε??List???????Object????????Object[]???顣
????????????????????hibernate??????????????
????????2???????????
Object tempObj=(Object)sumList.get(i);
sum1=tempObj==null?"0.0":tempObj.toString();
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11