@Override
public Integer getCount() {
return getHibernateTemplate().execute(new HibernateCallback<Integer>(){
@Override
public Integer doInHibernate(Session session) throws HibernateException {
String hql="select count(*) from Customer";
Query query = session.createQuery(hql);
int i = ((Long) query.setCacheable(true).uniqueResult()).intValue();
return i;
}
});
}
时间: 2024-10-13 23:14:31