首页 > 解决方案 > MyBatis 在使用 isInCaseInsensitiveWhenPresent 时给出空指针异常

问题描述

根据此处的 MyBatis 文档https://mybatis.org/mybatis-dynamic-sql/docs/conditions.html

如果传递了空值,则IsInCaseInsensitiveWhenPresent不应呈现。

所以,下面是我的查询:

 SelectStatementProvider selectStatement = select(allColumns())
                    .from(table1)
                    .where(table1.date1, isGreaterThanOrEqualToWhenPresent(from_))
                    .and(table1.date2, isLessThanWhenPresent(to_))
                    .and(table1.type, isInCaseInsensitiveWhenPresent(event))
                    .build()
                    .render(RenderingStrategies.MYBATIS3);

其中eventCollection类型的输入。

在这里,如果event为 null ,则查询呈现失败。那么,有什么建议吗?我想搜索一个列是否具有值列表中的值并且应该不区分大小写。

标签: javasqlmybatisibatis

解决方案


推荐阅读