【发布时间】:2023-03-14 00:07:01
【问题描述】:
我有以下匹配器:
Example.of(
user,
ExampleMatcher.matching()
.withMatcher("name", contains().ignoreCase())
.withMatcher("phoneNumber", contains())
)
除了null 值外,它工作正常。例如,不返回电话号码为NULL的用户。
我已尝试跟踪以包含 NULL 值,但没有成功:
Example.of(
user,
ExampleMatcher.matching()
.withMatcher("name", contains().ignoreCase())
.withIncludeNullValues()
.withMatcher("phoneNumber", contains())
.withIncludeNullValues()
)
生成的SQL如下:
select
user0_.id as id1_9_,
user0_.document_expiry_date as document2_9_,
user0_.document_type as document3_9_,
user0_.document_url as document4_9_,
user0_.email as email5_9_,
user0_.name as name6_9_,
user0_.phone_number as phone_nu7_9_
from
user user0_
where
(lower(user0_.name) like ?)
and (user0_.id is null)
and (user0_.document_type is null)
and (user0_.document_url is null)
and (user0_.email is null)
and (user0_.phone_number like ?)
and (user0_.document_expiry_date is null)
如何将其配置为也包含带有NULL 列的行?
【问题讨论】:
-
请添加生成的SQL语句。
-
@JensSchauder 在哪里可以找到生成的 SQL 语句?
-
配置你的 JPA 实现来记录它......然后你会在日志中找到它。
-
@JensSchauder 添加了生成的 SQL 语句。
标签: spring-data-jpa query-by-example