We have 2 nodes
@Node("User)
public class User {
@Id
private String id;
private String name;
}
@Node("Post")
public class Post {
@Id
@GeneratedValue(generatorClass = GeneratedValue.UUIDGenerator.class)
private UUID id;
private String text;
private Instant createdAt;
@Relationship(type = "AUTHOR", direction = Relationship.Direction.INCOMING)
private User author;
}
and we are trying to retrieve all the user's posts
@Query(value = "MATCH (author:User)-[:AUTHOR]-(post:Post) RETURN post, author",
countQuery = "MATCH (author:User)-[:AUTHOR]-(post:Post) RETURN count(post)")
Page<PostEntity> findPageByUserId(String userId, Pageable pageable);
We retrieve all the posts, but author is null in the Post
class
How to retrieve also the author?