隨筆-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
          主站蜘蛛池模板: 乌拉特前旗| 邵东县| 巫溪县| 静安区| 鄂尔多斯市| 井陉县| 京山县| 禄丰县| 龙井市| 永德县| 宜兰市| 长子县| 启东市| 泰来县| 鹰潭市| 连城县| 保靖县| 德化县| 肥城市| 海盐县| 阜城县| 两当县| 安陆市| 东平县| 家居| 正宁县| 龙陵县| 江山市| 洱源县| 古田县| 渭源县| 调兵山市| 墨脱县| 营口市| 凌云县| 鄂温| 镇江市| 许昌县| 镇安县| 任丘市| 乡宁县|