jquery网站模板下载,西安公司网站如何建设,青岛专业公司网站设计,中文wordpress主题下载getOne返回null 问题描述分析过程总结 问题描述
在数据库建了一张表主要包括两个字段master_id和slave_id;主要的额外字段max_lots 默认值是null#xff1b;
当调用getOne进行查询结果是null#xff0c;但实际情况是数据库时应该返回值的#xff1b;
AotfxMasterSlave ex… getOne返回null 问题描述分析过程总结 问题描述
在数据库建了一张表主要包括两个字段master_id和slave_id;主要的额外字段max_lots 默认值是null
当调用getOne进行查询结果是null但实际情况是数据库时应该返回值的
AotfxMasterSlave existMasterSlaveSql new AotfxMasterSlave();existMasterSlaveSql.setMasterId(masterId);existMasterSlaveSql.setSlaveId(slaveId);return this.aotfxMasterSlaveService.getOne(new QueryWrapper(existMasterSlaveSql));分析过程
为了查看完整的SQL语句执行情况mybatis-plus需要配置控制台打印完整带参数SQL语句。
application.yml
#mybatis-plus配置控制台打印完整带参数SQL语句
mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplapplication.properties
#mybatis-plus配置控制台打印完整带参数SQL语句
mybatis-plus.configuration.log-implorg.apache.ibatis.logging.stdout.StdOutImpl发现了问题在控制台输出的时候发现max_lots 也作为了条件进行查询原因在于我在实体类里面给max_lots设置了默认值 所以在数据库查询不到因为数据库max_lots的值都为null解决办法不要在实体类添加默认值通知修改查询语句为 this.aotfxMasterSlaveService.getOne(Wrappers.AotfxMasterSlavelambdaQuery().eq(AotfxMasterSlave::getMasterId, masterId).eq(AotfxMasterSlave::getSlaveId, slaveId));总结