Reputation: 25770
In my Spring Boot, Neo4j, SDN 5 OGM project I have the following composite entity:
@NodeEntity
public class User extends BaseEntity {
private static final String REFERRED_BY = "REFERRED_BY";
@Relationship(type = REFERRED_BY, direction = Relationship.OUTGOING)
private User referrerUser;
}
As you may see, one user may be referred by another.
Now, I'd like to receive a paginated result:
@Query(value = "MATCH (u:User) " +
"OPTIONAL MATCH (u)-[ruru:REFERRED_BY]->(ru:User) " +
"RETURN u, ruru, ru",
countQuery = "MATCH (u:User) " +
"OPTIONAL MATCH (u)-[ruru:REFERRED_BY]->(ru:User) " +
"RETURN count(u)")
Page<User> findUsers(Pageable pageable);
I request 0-50 users. But in the real data - one of them are referred by another:
Pageable pageable = PageRequest.of(0, 50, Sort.by(Sort.Direction.DESC, "u.createdAt"));
Page<User> userPage = userRepository.findUsers(pageable);
I expect not more than 50 items but as the result I receive 51
users in the Page.getContent()
...
Is this possible to hint somehow to no include User.referrerUser
into the Page.content
collection and just leave it as another user entity property (reference)?
What am I doing wrong and hot to fix it?
Upvotes: 0
Views: 26