public int selectAll(final String time1,
final String time2, final int cityname, final String airstatus) {
final StringBuffer hql = new StringBuffer(
"select count(air) from TableName air where air.cityname="
+ cityname + " and air.isDelete=0 and air.strtes1=1 and air.airstatus='" + airstatus + "'");
if (time1 != null && !time1.equals("")) {
hql.append(" and air.reportDate >=:time1");
}
if (time2 != null && !time2.equals("")) {
hql.append(" and air.reportDate <=:time2");
}
hql.append(" order by air.cityname asc ");
Number list = this.getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery(hql.toString());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
if (time1 != null && !time1.equals("")) {
query.setDate("time1", df.parse(time1));
}
if (time2 != null && !time2.equals("")) {
query.setDate("time2", df.parse(time2));
}
} catch (ParseException e) {
e.printStackTrace();
}
return query.uniqueResult();
}
});
return list.intValue();
}
详细解决方案
hibernate中的query.uniqueResult()统计回到一个整型数据
热度:601 发布时间:2013-11-16 23:15:33.0
相关解决方案
- hibernate 存入数据库当前时间
- hibernate DAO中加了局物,未提交
- hibernate 字段lazy 的兑现原理
- Hibernate 的query.list()的有关问题
- Hibernate 关联表字段赋值有关问题
- hibernate 联接mysql出错
- struts2 hibernate 分页有关问题
- hibernate与此同时使用多数据源?spring+hibernate
- hibernate 保留对象时,根据映射文件,无法获取主键值
- hibernate 多对1关联配置有关问题
- hibernate 一对1 ,插入不进去数据
- struts+spring+hibernate 开发,在action层调用service层接口,结果替null 注入失败,需高手帮忙
- SSH框架导入struts,hibernate,spring分先后顺序吗>>解决方法
- 请教小弟我不使用Myeclipse,可以在tomcat里面整合Spring,Hibernate,Struts2吗
- fatal error; call to a member function query() on a non-object异常求回答啊 php+sqlite
- Hibernate 保存数据有关问题本人初学者
- hibernate 用hql怎么实现子查询
- struts hibernate,该如何处理
- hibernate hql "=:"符号?解决思路
- null id in com.bsw.gms.hibernate.pojo.Score entry (don't flush the Session after an exception occurs,该怎么解决
- Hibernate flush机制的了解
- 求 Hibernate 3.32 API 汉语言文档
- 求1 struts 2+hibernate+spring整合好的项目
- ,Struts2+Hibernate+Spring做一个网站
- hibernate Save 指定值为函数有关问题(ORACEL库)
- hibernate Query.createQuery(queryString).list();查询最大只有1000条数据,该怎么处理
- hibernate 联合主键自增有关问题
- 哪位高手能推荐下开源的购物网站源码(struts+hibernate+spring)
- Spring+Struct2+Hibernate 集成有关问题
- Hibernate 缓存配置无效,该怎么解决