报错信息:
org.mybatis.spring.MyBatisSystemException: null at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439) ... Caused by: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'ew != null and ew.sqlSet != null'. Cause: org.apache.ibatis.ognl.OgnlException: sqlSet [com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not use this method for "getSqlSet"] at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48) at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32) at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34) at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32) ... Caused by: org.apache.ibatis.ognl.OgnlException: sqlSet Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not use this method for "getSqlSet" at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:49) at com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper.getSqlSet(LambdaUpdateChainWrapper.java:63) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.apache.ibatis.ognl.OgnlRuntime.invokeMethodInsideSandbox(OgnlRuntime.java:1245) ...
报错原因:
//serviceImpl代码
baseMapper.update(this.lambdaUpdate().eq(Order::getId, order.getId()).set(Order::getStatus, Order.Status.STORE_SUBMIT.getCode()) .set(Order::getUpdatedId, sysUser.getId()).set(Order::getUpdatedTime, LocalDateTime.now()))
//注意this.lambdaUpdate()的只用方法,该方法返回对象LambdaUpdateChainWrapper<T>,虽然该对象也是Wrapper<T>的子类,所以下面写法不会编译报错,但是执行时会报错,LambdaUpdateChainWrapper<T>对象不能直接用baseMapper对象去执行
//this.update()方法与this.lambdaUpdate()相同
//this.lambdaUpdate()的正确用法如下(最后直接调用.update()方法去执行修改sql,或调.remove()方法执行删除sql)
this.lambdaUpdate().eq(Order::getId, order.getId()).set(Order::getStatus, Order.Status.STORE_SUBMIT.getCode())
.set(Order::getUpdatedId, sysUser.getId()).set(Order::getUpdatedTime, LocalDateTime.now()).update()
//同样this.lambdaQuery()的正确用法是调.list()方法执行查询sql,代码如下
//this.query()方法与this.lambdaQuery()相同
this.lambdaQuery().eq(Order::getId, order.getId()).list();
解决方法:使用正确的调用方式
//baseMapper.selectList()的正确调用方式如下
baseMapper.selectList(Wrappers.lambdaQuery(Order.class).eq(Order::getId, "id"));
baseMapper.selectList(new LambdaQueryWrapper<Order>().eq(Order::getId, "id"));
//baseMapper.update()的正确调用方式如下
baseMapper.update(Wrappers.lambdaUpdate(Order.class).eq(Order::getId, "id").set(Order::getStatus, 1));
baseMapper.update(new LambdaUpdateWrapper<Order>().eq(Order::getId, "id").set(Order::getStatus, 1));
希望对你有帮助
标签:ibatis,java,getId,BuilderException,apache,org,ew,null,Order From: https://www.cnblogs.com/luolei0120/p/18375456