posts - 4, comments - 10, trackbacks - 0, articles - 2

          請教一個hibernate分頁問題

          Posted on 2007-04-23 15:08 samfree 閱讀(76) 評論(0)  編輯  收藏

          我在用hibernate對mysql進行分頁的方法
          /**
            * 函數說明:獲得所有的信息
            * 參數說明:
            * 返回值:信息的集合
            */
           public List getProducts(final int pageSize, final int startRow) throws HibernateException { 
               return this.getHibernateTemplate().executeFind(new HibernateCallback(){

                   public Object doInHibernate(Session session) throws HibernateException, SQLException {
                  
                       Query query=session.createQuery("FROM Products as p");
                       query.setMaxResults(pageSize);
                       query.setFirstResult(startRow);    
              
                       List list = query.list();
                 
                       return list;
                   }
                  });

           }

          運行時怎么老給出異常阿?請幫幫我看看好嗎?
          org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
          org.hibernate.exception.SQLGrammarException: could not execute query
          java.sql.SQLException: Syntax error or access violation,  message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '40 products0_.game_id as game1_0_, products0_.game_name_en as game2_0_, products' at line 1"


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 伊宁市| 盐山县| 山阳县| 荃湾区| 资源县| 平潭县| 临泽县| 沅陵县| 河间市| 富阳市| 宾阳县| 台湾省| 柯坪县| 垣曲县| 高平市| 三明市| 台前县| 乌兰浩特市| 垫江县| 武城县| 通山县| 洪泽县| 石楼县| 浪卡子县| 东兴市| 崇仁县| 正镶白旗| 大厂| 德州市| 兰州市| 利辛县| 汶川县| 航空| 丰县| 云浮市| 麻栗坡县| 新竹县| 阳原县| 北票市| 休宁县| 临朐县|