Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-02-2018 04:44 AM
Hi,
I'm trying to get the node entity along with relationship using spring data. Relationship values are not being binded when I annotated with '@Relationship' tag.
For Ex., User has list of task linked through task_status. I would like to query the list of pending tasks(task_status).
/** In UserRepository.java **/
match(u:user {email : {0})-[rel:PENDING]-(t:task) return u, rel, t
User getPendingTasks(String email);
/** User Entity **/
@NodeEntity(label="user")
public class User {
private Long id;
private String email;
@Relationship(type = "PENDING")
private List<Task> tasks = new ArrayList<>();
...
}
/** Relationship Entity **/
@RelationshipEntity(type = "PENDING")
public class TaskStatus {
@Id
private Long id;
@Property
private String status;
@StartNode
private User user;
@EndNode
private Task task;
}
/** In Service **/
User user = userRepository.getPendingTasks(email);
return user.getTasks(); //Yields No data
Like JPA entity, will the associated relationship is not being bound??
10-03-2018 12:17 PM
Does it make any difference if you indicate the directionality, e.g.
@Relationship(type = "PENDING", direction = Relationship.OUTGOING)
10-10-2018 03:00 PM
What versions of Spring Data Neo4j and Neo4j-OGM do you use in the project?
I am asking because this should work in any version 3.+ of Neo4j-OGM. I just tested this with the same repository method you defined. There are just closing parenthesis and the@Query
annotation missing in your example, or is there more in the query?
The direction can be omitted in this case because OUTGOING
is the default direction.
Edit: are you also defining the lower-case task
for the Task
type in your entity definition? Your query does also use a lower-case label for the tasks.
All the sessions of the conference are now available online