确认

  • [X] 我使用的版本是最新版, 并且使用插件确认过项目里无依赖版本冲突
  • [X] 我已经在 issue 中搜索过, 确认问题没有被提出过
  • [X] 我已经修改标题, 将标题中的 描述 替换为遇到的问题

当前程序版本

3.5.7

问题描述

@AllArgsConstructor
@Getter
public enum StateEnum {
  PENDING(1),
  ;
  @EnumValue
  private final Integer value;
}

正常:

<if test="state != null">
  and state = #{state}
</if>

报错:

<if test="state != null and state > 0">
  and state = #{state}
</if>

详细堆栈日志

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NumberFormatException: For input string: "PENDING"
### Cause: java.lang.NumberFormatException: For input string: "PENDING"
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439)
    at com.sun.proxy.$Proxy121.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:164)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at com.sun.proxy.$Proxy142.list(Unknown Source)

Comment From: miemieYaho

typehandler不在那个位置生效

Comment From: duanluan

typehandler 不在那个位置生效

好吧,那如果要判断参数还有点麻烦……如果能想办法在那生效就好了

Comment From: miemieYaho

xx.value > 0 呢?

Comment From: duanluan

xx.value > 0 呢?

这样可以的谢谢