如题
报错内容如下:
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT * FROM( SELECT bwi.id AS word_id, bwi.word_spell, bwi.view_chapter_id FROM auto_student_test_question astq LEFT JOIN base_word_info bwi ON astq.word_id = bwi.id WHERE astq.del_flag = '0' AND astq.`status` = '0' AND astq.class_code = ? AND astq.student_code = ? AND astq.book_id = ? AND astq.test_result = '2' UNION SELECT bwi.id AS word_id, bwi.word_spell, bwi.view_chapter_id FROM word_student_note wsn LEFT JOIN base_word_info bwi ON wsn.word_id = bwi.id WHERE wsn.del_flag = '0' AND wsn.`status` = '0' AND wsn.class_code = ? AND wsn.student_code = ? AND wsn.book_id = ? AND wsn.error_count != 0) unionTable LIMIT ?,?
### Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
1.service 代码:
List<ClassErrorWordResponse> words = autoClassNoteService.selectStudentErrorWordInfo(request.getPage(),
request.getClassCode(), request.getStudentCode(), request.getBookId());
2.Mapper.java 代码
List<ClassErrorWordResponse> selectStudentErrorWordInfo(@Param("page") Page<ClassErrorWordResponse> page, @Param("classCode") String classCode, @Param("studentCode") String studentCode, @Param("bookId") Long bookId);
3.mapper.xml 代码
SELECT DISTINCT
a.word_id,
a.word_spell,
a.view_chapter_id
FROM(
SELECT bwi.id AS word_id,
bwi.word_spell,
bwi.view_chapter_id
FROM auto_student_test_question astq
LEFT JOIN base_word_info bwi ON astq.word_id = bwi.id
WHERE astq.del_flag = '0'
AND astq.`status` = '0'
AND astq.class_code = #{classCode}
AND astq.student_code = #{studentCode}
AND astq.book_id = #{bookId}
AND astq.test_result = '2'
UNION
SELECT bwi.id AS word_id,
bwi.word_spell,
bwi.view_chapter_id
FROM word_student_note wsn
LEFT JOIN base_word_info bwi ON wsn.word_id = bwi.id
WHERE wsn.del_flag = '0'
AND wsn.`status` = '0'
AND wsn.class_code = #{classCode}
AND wsn.student_code = #{studentCode}
AND wsn.book_id = #{bookId}
AND wsn.error_count != 0) a
各种尝试感觉是因为最外层的子查询导致的,sql 是没问题的,打印出来的 sql 丢 navicat 里正常运行,并且如果不分页的话 sql 也正常,只要带着分页就会报错。大家有遇到过的吗?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.