同一条SQL语句,myBatis查出来的数据和Navicat查出来的数据不同

通过日志打印的mybatis执行的SQL语句,原原本本复制到数据库,可以查出来很多条数据,但是mybatis要么查不到,要么少数据。
1.已尝试过写死传入参数,证明不是参数问题
2.尝试过select *,无效
3.尝试过查询的数据不小于resultMap里面的数据,也无效
4.写一个POJO类(是叫DTO吧?)来接收数据,也无效
5.SQL语句很简单,而且是通过复制到数据库,以及属性名都是通过复制,不存在写错。

走投无路了。。

以下是代码段以及日志:
日志:

 2018-07-02 14:05:00,244 DEBUG [org.mybatis.spring.SqlSessionUtils] - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49]
2018-07-02 14:05:00,244 DEBUG [org.mybatis.spring.SqlSessionUtils] - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49] from current transaction
2018-07-02 14:05:00,244 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==>  Preparing: select v.VideoStream videoStream,v.FileSize fileSize,v.Quality quality,v.UserType userType from vod_videorecord v where trim(v.RoomID) = ? 
2018-07-02 14:05:00,244 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==> Parameters: 9(Integer)
2018-07-02 14:05:00,316 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - <==      Total: 17
2018-07-02 14:05:00,316 DEBUG [org.mybatis.spring.SqlSessionUtils] - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49]
2018-07-02 14:05:00,316 DEBUG [org.mybatis.spring.SqlSessionUtils] - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49] from current transaction
2018-07-02 14:05:00,316 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==>  Preparing: select v.VideoStream videoStream,v.FileSize fileSize,v.Quality quality,v.UserType userType from vod_videorecord v where trim(v.RoomID) = ? 
2018-07-02 14:05:00,316 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==> Parameters: 3(Integer)
2018-07-02 14:05:00,393 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - <==      Total: 1143
2018-07-02 14:05:00,394 DEBUG [org.mybatis.spring.SqlSessionUtils] - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49]
2018-07-02 14:05:00,394 DEBUG [org.mybatis.spring.SqlSessionUtils] - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49] from current transaction
2018-07-02 14:05:00,394 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==>  Preparing: select v.VideoStream videoStream,v.FileSize fileSize,v.Quality quality,v.UserType userType from vod_videorecord v where trim(v.RoomID) = ? 
2018-07-02 14:05:00,394 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==> Parameters: 2(Integer)
2018-07-02 14:05:00,472 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - <==      Total: 36
2018-07-02 14:05:00,472 DEBUG [org.mybatis.spring.SqlSessionUtils] - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49]
2018-07-02 14:05:00,472 DEBUG [org.mybatis.spring.SqlSessionUtils] - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5f2b1d49] from current transaction
2018-07-02 14:05:00,472 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==>  Preparing: select v.VideoStream videoStream,v.FileSize fileSize,v.Quality quality,v.UserType userType from vod_videorecord v where trim(v.RoomID) = ? 
2018-07-02 14:05:00,472 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - ==> Parameters: 1(Integer)
2018-07-02 14:05:00,546 DEBUG [com.talk915.liveManagement.webapp.dao.group.VideoRecordDao.getDataByRoomIdforquery] - <==      Total: 575

以最后一条查询语句为例
: select v.VideoStream videoStream,v.FileSize fileSize,v.Quality quality,v.UserType userType from vod_videorecord v where trim(v.RoomID) = ?

参数:1
返回条数:575条
数据库数据: 594条

这是差的少的情况,差的多了,直接差了几百,一千条数据都是..

数据库数据:
图片说明

mapper里面代码段:
图片说明

这种情况,一般是数据库链接搞错导致。请认真检查数据库链接。

数据库连接错误问题 或者使用的框架里滤掉了某些特殊数据

没遇到过,不过一般单词查询数据大于50条都用分页查询了把。你这样一次查询几百条数据感觉有点不合适。拙见。

有可能是数据格式的问题,parameterType是java.lang.Integer,改成java.lang.String试一下

建议反向的思路查问题:先正面面对已知缺少数据的问题,然后如下思路去查看看
1.明确相同条件下两种方式获取数据并保存,分析其中每次执行查询是否都一样(缺少的数据也是一样的不?)
2.对比缺少的数据内容是否有规律

比如大概看了下截图其中fiseSize代码声明对应是INTERGE类型,数据库中有未赋值的记录,是否无法自动映射到结果集可能?

把resultMap的type改成java.util.Map试试

原因:
mybaties映射时使用主键判断唯一性,如果查询出来的数据集在映射文件配置中没有设置主键或者主键存在相同的情况下,MyBaties之映射其中一条

解决方法:
给查询出来的结果加上主键字段,在MyBaties的映射文件中也进行配置

解决了,确实是数据库链接导致的.. 我链接的是xx1数据库,查的表是xx2数据库的表,因为其他的查询都有加上xx2.[表名],忽略了造成这种错误的可能性。谢谢大家。