标签:etc cti on() lis commit blog 技术 ssi image
1. 获取总的记录数
Session session = HibernateUtils.getCurrentSession();
Transaction tr = session.beginTransaction();
List<Number> list = session.createQuery("select count(c) from Customer c").list();
Long count = list.get(0).longValue();
System.out.println(count);
tr.commit();
2. 获取某一列数据的和
Session session = HibernateUtils.getCurrentSession();
Transaction tr = session.beginTransaction();
List<Number> list = session.createQuery("select sum(c.cust_id) from Customer c").list();
Long count = list.get(0).longValue();
System.out.println(count);
tr.commit();
标签:etc cti on() lis commit blog 技术 ssi image
原文地址:http://www.cnblogs.com/llforeverlove/p/6441386.html