hibernate取记录总数

public int getMaxRow(String brchNo,
String sDate, String eDate, String carID, String statusInput,
String companyNo, String codeNo) {
try {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();

if(carID == null)
carID = "-";
if(carID.length() == 0)
carID = "-";


 
String queryString = "";
if (codeNo.equals("0"))
queryString = "select  count(*) from T33CarinsuranceOrder t, customerQT t1, CarInsurCompany t2 where t1.shenfenID = t.ownerid and t1.carNum = t.carnumber and t.companyid = t2.company_id and t.companyid = '"
+ "02"
 
+ "' and ((t.carnumber = '"
+ carID 
+ "') or ('"
+ carID
+ "' = '-')) and t.orderstatus in ('05', '06') and ((t.datezhifu between '"
+ "20010101"
+ "' and '"
+ "20800101"
+ "') or (t.dateshoukuan between '"
+  "20010101"
+ "' and '"
+ "20800101"
+ "')) and (t.txnbranch in        (select t6.brchNo from TBrchMng t6 where t6.counBrch = '"
+ brchNo
+ "') or  t.txnbranch in        (select t7.brchNo from TBrchMng t7 where t7.cityBrch = '"
+ brchNo
+ "') or        t.txnbranch in        (select t8.brchNo from TBrchMng t8 where t8.provBrch = '"
+ brchNo
+ "') or        t.txnbranch in        (select t9.brchNo from TBrchMng t9 where t9.brchNo = '"
+ brchNo + "'))  "; 

 
/*
* private String applicantmobile; private String recipientadress;
* private String PKG_NAME; private String productId;
*/


System.out.println(queryString);
Query query = session.createQuery(queryString); 
 
Long count = ((Long)query.iterate().next()).longValue();
 
//Integer count = (Integer) it.next();
//String count = (String) object[0]; 
System.out.println("记录条数" + count.intValue());
return (count).intValue();
} catch (RuntimeException re) {
log.error("查询订单和车辆信息失败", re);
// log.error("find by property name failed", re);
throw re;
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值