Hibernate得到数据库表的记录数
public Integer count() {
SessionFactory sessionFactory = SessionFactoryUtil.getSessionFactory();
//EntityClass改成表名所映射的类的字节码
Criteria criteria = session.createCriteria(EntityClass);
criteria.setProjection(Projections.rowCount());
Object ojb = criteria.uniqueResult();
Long lojb = (Long)ojb;
int count = lojb.intValue();
return count;
}