数据库执行结果和mybatis执行结果不一致

时间:2017-11-17 03:19:31

标签: mysql mybatis spring-mybatis

使用:

SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@54b0f2cd] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://xxxx/xxxx, UserName=xxxx@xxxx, MySQL-AB JDBC Driver] will not be managed by Spring
==>  Preparing: select IFNULL(count(*),0) from goods_info 
==> Parameters: 
<==    Columns: IFNULL(count(*),0)
<==        Row: 149
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@54b0f2cd]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@25b99cbf] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://xxxx/xxxx, UserName=xxxx@xxxx, MySQL-AB JDBC Driver] will not be managed by Spring
==>  Preparing: select sum(browsed_times) from goods_info 
==> Parameters: 
<==    Columns: sum(browsed_times)
<==        Row: 10128
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@25b99cbf]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5d271b1a] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://xxxx/xxxx, UserName=xxxx@xxxx, MySQL-AB JDBC Driver] will not be managed by Spring
==>  Preparing: select IFNULL(count(*),0) from user 
==> Parameters: 
<==    Columns: IFNULL(count(*),0)
<==        Row: 694
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5d271b1a]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@20bbe729] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://xxxx/xxxxx, UserName=xxxx@xxxx, MySQL-AB JDBC Driver] will not be managed by Spring
==>  Preparing: select IFNULL(sum(total_price),0) from order_build where order_status = '已支付' 
==> Parameters: 
<==    Columns: IFNULL(sum(total_price),0)
<==        Row: 0.00
<==      Total: 1

在数据库中,我除了四个sql,这里有日志:

<select id="getTotalMoney" resultType="String">
    select IFNULL(sum(total_price),0)
    from order_build
    where order_status =
    '已支付'
</select>

现在我发现前三个与数据库一致,但最后一个是错误。当我在数据库中执行它时,我可以得到正确的结果。

这是我的mapper.xml:

input

在数据库中,我得到了这个结果:

enter image description here

我很沮丧。我不知道为什么。

1 个答案:

答案 0 :(得分:0)

Reslove。 我用utf8指定编码。