您的位置:首页 > 其它

hibernate取记录总数

2014-06-13 16:28 141 查看
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;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: