当前使用版本(必填,否则不予处理)

3.4.3.3

该问题是如何引起的?(确定最新版也有问题再提!!!)

最新版3.5.1也有这个问题, 3.4.2就没这个问题,我从3.4.2升级到3.4.3.3后就开始出现

重现步骤(如果有就写完整)

entity 继承 Model然后调用 insert()方法出现这个错误

报错信息

com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Class must not be null at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:49) ~[mybatis-plus-core-3.5.1.jar:3.5.1] at com.baomidou.mybatisplus.core.toolkit.Assert.isTrue(Assert.java:38) ~[mybatis-plus-core-3.5.1.jar:3.5.1] at com.baomidou.mybatisplus.core.toolkit.Assert.notNull(Assert.java:72) ~[mybatis-plus-core-3.5.1.jar:3.5.1] at com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils.currentSessionFactory(GlobalConfigUtils.java:53) ~[mybatis-plus-core-3.5.1.jar:3.5.1] at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.sqlSession(SqlHelper.java:86) ~[mybatis-plus-extension-3.5.1.jar:3.5.1] at com.baomidou.mybatisplus.extension.activerecord.Model.sqlSession(Model.java:248) ~[mybatis-plus-extension-3.5.1.jar:3.5.1] at com.baomidou.mybatisplus.extension.activerecord.Model.insert(Model.java:56) ~[mybatis-plus-extension-3.5.1.jar:3.5.1]

Comment From: miemieYaho

代码呢

Comment From: VampireAchao

麻烦提供一下测试用例,可以吗

Comment From: a386572631

我也发现了,只要是.one()的没找到记录好像就会报,以前是会返回个null的。 3.5.3版本

Comment From: wheatmai

我也发现了,只要是.one()的没找到记录好像就会报,以前是会返回个null的。 3.5.3版本

对,我也是 3.5.3, lambda使用one()时,如果没记录就报异常。BaseMapper的selectOne方法正常返回了Null,但后面那个包装方法里面wrapper的entityclass是空的

Comment From: nieqiurong

Reference in new issu

这个应该更新到3.5.3.1试试.

Comment From: bydongxing

直接使用 QueryWrapper 也是同样的问题,版本是 3.5.3.1的 QueryWrapper entityWrapper = new QueryWrapper(); model.selectList(entityWrapper);

Comment From: nieqiurong

直接使用 QueryWrapper 也是同样的问题,版本是 3.5.3.1的 QueryWrapper entityWrapper = new QueryWrapper(); model.selectList(entityWrapper);

还有问题就提供一个工程过来看看吧

MyBatis-Plus 调用model.insert()方法报class must not be null

Comment From: honestAnt

MyBatis-Plus 调用model.insert()方法报class must not be null MyBatis-Plus 调用model.insert()方法报class must not be null MyBatis-Plus 调用model.insert()方法报class must not be null

MyBatis-Plus 调用model.insert()方法报class must not be null 问题其实出现在 使用service的lambdaQuery()方法,该方法内部初始化entityClass的时候 把对象设置为 wrapperChildren 的属性了,外面的entityClass属性没设置,导致获取的时候为null ;建议官方在 LambdaQueryChainWrapper.getEntityClass()方法内部做个优化处理

Comment From: honestAnt

或者升级到最新版本 3.5.3.2 已经修复了; MyBatis-Plus 调用model.insert()方法报class must not be null