我在使用Spring Data MongoDB Repository时遇到了一个奇怪的问题。 我想从我的findAll
请求中排除一个字段。 我该如何实现?
这是完美的:
@Query(fields = "{'objectContentAsJson':0}")
Page<ObjectHistory> findByObjectIdAndServiceIgnoreCase( String objectId, String service, Pageable pageable );
但是findAll
没有机会:
@Query(fields = "{'objectContentAsJson':0}")
Page<ObjectHistory> findAll( Pageable pageable );
这会抛出以下异常:
Caused by: org.springframework.data.mapping.PropertyReferenceException: 找不到类型为ObjectHistory的属性findAll! at org.springframework.data.mapping.PropertyPath.(PropertyPath.java:75) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241) at org.springframework.data.repository.query.parser.Part.(Part.java:76)