日期:2014-05-17 浏览次数:20713 次
public class DeviceAlarmDAOImpl extends HibernateDaoSupport implements DeviceAlarmDAO { private HibernateTemplate ht; public void init() { ht = getHibernateTemplate(); } 。。。。。。。 Session session = this.getSession(); String hql = "select count(alarmID) from DeviceAlarmInfo"; int total = 0; try { Query query = session.createQuery(hql); total = ((Number) query.uniqueResult()).intValue(); return Integer.valueOf(total); } catch (Exception e) { e.printStackTrace(); return 0; } finally { session.close(); }