/**
* 使用 hql 語句進行操作
* @param hql HSQL 查詢語句
* @param offset 開始取數據的下標
* @param length 讀取數據記錄數
* @return List 結果集
*/
public List getListForPage ( final String hql , final int offset , final int length ) {
List list = getHibernateTemplate().executeFind ( new HibernateCallback ( ) {
public Object doInHibernate ( Session session ) throws HibernateException, SQLException {
//final String queryString = "from Fourm f where f.identity='" + property+"'";
Query query = session.createQuery ( hql ) ;
// query.setString(0, value); //設置查詢參數
query.setFirstResult ( offset ) ;
query.setMaxResults ( length ) ;
List list = query.list ( ) ;
return list ;
}
}) ;
return list ;
}
posted on 2008-09-09 11:47
紫蝶∏飛揚↗ 閱讀(596)
評論(3) 編輯 收藏 所屬分類:
Hibernate