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;
}
}
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;
}
}
相关文章推荐
- Hibernate使用count(*)取得表中记录总数
- Hibernate中如何使用count(*)取得表中记录总数
- Hibernate 统计记录总数方法汇总
- Hibernate使用count(*)取得表中记录总数(跨Hibernate3.x版本问题)(转)
- Hibernate中如何使用count(*)取得表中记录总数
- Hibernate中如何使用count(*)取得表中记录总数
- Hibernate使用count(*)取得表中记录总数
- Hibernate中使用count(*)统计记录总数
- hibernate中, 计算某列非重复记录的总数, 使用COUNT + DISTINCT
- Hibernate 统计记录总数方法汇总
- Hibernate使用count(*)取得表中记录总数
- NHibernate使用Criteria分页显示并返回记录总数 【转】
- Log4j2配置文件记录hibernate
- 异常记录001—hibernate 4.2.4 Final 测试出现Connection cannot be null when 'hibernate.dialect' not set
- hibernate分组查询后,求分组总数的实现方法(管理系统分页)
- [NHibernate]获取分组查询的记录总数
- Hibernate第一课总结(往Sqlserver2000中employee表中添加一条记录)
- Hibernate实现记录的增、删、改和查功能
- Hibernate保存记录时遇到的一个问题----evitic,not-null配置及主键生成策略
- Hibernate快速入门案例——手动增加记录