> For the complete documentation index, see [llms.txt](https://ankang.gitbook.io/commons/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ankang.gitbook.io/commons/commons-jpa/gong-neng/kong-zhi-chu-li.md).

# 空值处理

默认情况下，查询条件构建过程会直接忽略查询对象中的`null`字段。如果使用者希望将`null`也加入到条件中，需配置`@QueryCondition(policy=NullPolicy.INCLUDE)`。

对于字符串类型的查询条件，默认会进行去除首尾空白字符的处理，如果不希望使用这一特性，使用者需要配置`@QueryCondition(trim=false)`。

```java
class Foo {
    Long id;
    String name;
    String content;
}
class FooQo {
    @QueryCondition
    String name;
    @QueryCondition(policy=NullPolicy.INCLUDE)
    String content;
}

FooQo fooQo = new FooQo("foo ", null);
Specification<Foo> specification = SpecificationFactory.getSpecification(fooQo);
List<Foo> foos = fooRepository.findAll(specification);
```

生成的SQL：

```sql
SELECT * FROM FOO
WHERE FOO.NAME = 'foo'
	AND FOO.CONTENT IS NULL;
```
