隨筆-86  評論-33  文章-0  trackbacks-0
          public  List find( final  String hsql,  final   int  firstRow,  final   int  maxRow)  throws  Exception { 
            
          return  getHibernateTemplate().executeFind( new
           HibernateCallback() { 
               public  Object doInHibernate(Session s)  throws
           HibernateException, SQLException { 
                     Query query 
          =
           s.createQuery(hsql); 
                     query.setFirstResult(firstRow); 
                     query.setMaxResults(maxRow); 
                     List list 
          =
           query.list(); 
                     return
           list; 
                     } 
               }); 
          }
           

          posted on 2006-08-28 14:53 Derek.Guo 閱讀(4587) 評論(4)  編輯  收藏 所屬分類: Java

          評論:
          # re: Spring Hibernate 模板實(shí)現(xiàn)分頁 2008-06-21 10:46 | BinTime
          Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
          兄弟我安你寫的測試總報這個錯,什么原因啊  回復(fù)  更多評論
            
          # re: Spring Hibernate 模板實(shí)現(xiàn)分頁 2008-07-29 15:12 | Derek.Guo
          @BinTime
          你的數(shù)據(jù)源不行吧!!先測試你的數(shù)據(jù)庫連接!  回復(fù)  更多評論
            
          # re: Spring Hibernate 模板實(shí)現(xiàn)分頁 2008-10-21 10:42 | lan
          參數(shù)什么意思?可以稍微說明下不?謝謝  回復(fù)  更多評論
            
          # re: Spring Hibernate 模板實(shí)現(xiàn)分頁[未登錄] 2008-10-21 18:43 | Derek.Guo
          三個參數(shù),第一個是HQL語句,如from Users
          第二個是從第幾條記錄開始
          第三個是分頁的頁顯示條數(shù)大小
          find("from Users",10,20);
          表示查詢Users 表,從第10條記錄開始,共查詢出20條記錄   回復(fù)  更多評論
            
          MSN:envoydada@hotmail.com QQ:34935442
          主站蜘蛛池模板: 德令哈市| 剑阁县| 永定县| 洛川县| 胶南市| 邯郸市| 西乡县| 汝阳县| 吉隆县| 星座| 乳源| 武强县| 嘉善县| 新化县| 大冶市| 天水市| 澄江县| 大渡口区| 永平县| 石门县| 安阳市| 兴和县| 板桥市| 晋宁县| 靖安县| 营口市| 唐海县| 古蔺县| 天长市| 环江| 封开县| 永济市| 汝南县| 会泽县| 北京市| 宁波市| 新泰市| 井研县| 铜川市| 肇庆市| 古蔺县|