Following is the model with A
(UserN) and B
(UserRoleN) as objects.
@NodeEntity()
public class UserN
{
@GraphId
private Long id;
@Relationship(type = "hasRole", direction = Relationship.OUTGOING)
private List<UserRoleN> role;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setRole(List<UserRoleN> role) {
this.role = role;
}
public List<UserRoleN> getRole() {
return role;
}
}
@NodeEntity()
public class UserRoleN
{
@GraphId
private Long id;
private String name;
public Long getName() {
return version;
}
public void setName(String name) {
this.name = name;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
}
In the database, following is graph structure:
A->B
While loading A, session.load(A.class, id, 1)
, a total of 2 B-Objects are loading under A Object in which one of the B's ID is null and other B object ID is neo4j generated.
Unable to understand why the duplicate B is loaded where Database has only one B Object.