【发布时间】:2016-05-21 21:59:51
【问题描述】:
我对 spring 数据 mongodb 存储库有一个奇怪的问题。我想从我的 findAll 请求中排除一个字段。我怎样才能做到这一点?
这很好用:
@Query(fields = "{'objectContentAsJson':0}")
Page<ObjectHistory> findByObjectIdAndServiceIgnoreCase( String objectId, String service, Pageable pageable );
但findAll没有机会:
@Query(fields = "{'objectContentAsJson':0}")
Page<ObjectHistory> findAll( Pageable pageable );
这会抛出:
原因: org.springframework.data.mapping.PropertyReferenceException:否 找到类型 ObjectHistory 的属性 findAll!在 org.springframework.data.mapping.PropertyPath.(PropertyPath.java:75) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) 在 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) 在 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241) 在 org.springframework.data.repository.query.parser.Part.(Part.java:76)
【问题讨论】:
标签: java spring mongodb repository spring-data-mongodb