具有分頁功能的idea單元測試問題【nested exception is org.apache.ibatis.exception..PersistenceException】
阿新 • • 發佈:2019-01-03
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.hibernate.exception.SQLGrammarException: 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 ''1','2'' at line 11 ### The error may exist in file [D:\0.Zhaoshuihao\git-vein-api\target\classes\mybatis\AbilityMapper.xml] ### The error may involve com.scysun.repository.vein.AbilityImplDao.getAbilityComment-Inline ### The error occurred while setting parameters ### SQL: select ubi.avatar,ubi.nick_name as nickName,ac.create_time,ac.user_id as userId,ac.content, ( select GROUP_CONCAT(image_url) from t_images where model_id=ac.id group by model_id) as pics from t_ability_comment ac inner join t_user_basic_info ubi on ubi.user_id=ac.user_id where 1=1 AND ac.ability_id=? order by ac.create_time desc limit ?,? ### Cause: org.hibernate.exception.SQLGrammarException: 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 ''1','2'' at line 11
下面是我的單元測試類,具有分頁功能。後面會講到,問題就出在分頁的地方
注意我傳給 pageIndex和pageSize的數字都用雙引號引起來了,問題就出在這裡,因為分頁的時候,傳給分頁的引數需是int型別的,而這裡用雙引號,就表明這是個String型別的,所以會報錯,把引號去掉後,就測試成功 了!還是型別的問題