ExampleMatcher.withIgnorePath正在获取被忽略的属性路径

时间:2018-07-03 11:30:28

标签: hibernate spring-mvc spring-boot jpa spring-data-jpa

我有一个具有多个属性路径的实体。我使用了“按示例查询”和“ ExampleMatcher”来忽略某些属性路径。

我的实体如下所示, Employee.class

private Integer id;
private String name;
private String designation;

我只想显示实体(表中的字段)的名称和ID。为此,我做了以下事情,

ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnoreNullValues().withIgnorePaths("designation");
Example<Employee> example = Example.of(entity, exampleMatcher);

但是,响应返回所有值,包括ignorePath中给定的属性。

请协助我如何忽略属性路径。

2 个答案:

答案 0 :(得分:6)

for i in sftp.listdir_attr(path): print i.st_size 防止基于示例的查询基于示例的withIgnorePaths("designation")值应用 filter 。它不会阻止在查询结果中填充designation

如果要从查询结果中排除某些属性,请使用projectionsquery graphs(取决于哪种情况更适合您的特定用例)。不过,不确定是否可以通过示例查询使用它们。

答案 1 :(得分:1)

我不确定这是否行得通

ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnorePaths("designation").withIgnoreNullValues();

我刚添加了withIgnorePaths

引用This link

相关问题