1、hql分页
String queryString = "from EqpEquipment model " + conditions + " and "
+ GlobalRoleUtil.getResourceAuthConditions("model.equipcode") + " order by nlssort(equipname,'NLS_SORT=SCHINESE_PINYIN_M')";
session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
Query query = session.createQuery(queryString);
query.setFirstResult(curpage * pagesize);
query.setMaxResults(pagesize);
return query.list().toArray();
2、sql分页
SQLQuery query = this.getSessionFactory().getCurrentSession().createSQLQuery(sql + where)
<span style="background-color: rgb(255, 255, 153);">.addEntity("t", TgsPassedcarHis10.class);</span>
query.setFirstResult(cp * ps);
query.setMaxResults(ps);
return query.list();
3、hql查询数量(int)
<span style="white-space:pre"> </span> Query query = this.getSessionFactory().getCurrentSession().createQuery(sql + where);
int temp = Integer.parseInt(String.valueOf(query.uniqueResult()));
return temp;
<span style="white-space:pre"> </span> String quertString = "select count(*) from SysPoint as model "+condition;
<span style="white-space:pre"> </span> return ((long)getHibernateTemplate().find(queryString).listIterator().next()).intValue();
// <span style="font-family: Arial, Helvetica, sans-serif;"> return ((Number)getHibernateTemplate().find(queryString).listIterator().next()).intValue();</span>
4、sql查询数量(long)
Long i =(Long) this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(*) from EqpEquipment t ").uniqueResult();
return ""+i;