记一次大坑:mybatis查询结果和接收的不一样,折腾我好几个小时.
先上代码:代码是要查询排名,sql执行的结果
SELECT
b.operator_id,
b.class_count,
b.class_study,
b.student_count,
b.rownum AS rank,
b.rownum AS praiseSum
FROM
(
SELECT
concat((@rownum :=@rownum + 1) + 0, '') AS rownum,
operator_id,
class_count,
class_study,
student_count
FROM
(SELECT @rownum := 0) AS foo,
appraise_list
WHERE
base_id = 120
ORDER BY
class_count DESC
) b
WHERE
b.operator_id = 233
结果,用对象接收的时候,这个字段怎么都是rank=4.
这就让我觉得很奇怪了,最后找到https://blog.csdn.net/bwddd/article/details/80264697 这个博客.
粗看感觉没啥联系啊,不过还是抱着尝试的态度,试了下,尽然好了
原mybatis.xml文件
修改后的文件:
修改后,尽然特么好了!!!!不清楚原因,等有机会再去了解吧,记录一下.