Recently starting with neo4j and converting a program into using OGM. Have been able to get everything saved into the database just fine, however when retrieving, OGM seems to get confused on node types and relationships in this instance:
(LOCATION)<---[VISITED]---(PERSON)---[CORRESPONDED]--->(LOCATION)
When I do my get().load(Person.class, id, 1), I get the Person and the CLOTHING nodes just fine, but only the VISITED is attached to the returned Person Node and my CORRESPONDED set is null.
In the database, based on viewing in the browser, both LOCATION nodes are made and have the proper relationships on them
@NodeEntity
public class Person extends Entity {
@Relationship(type = RelationshipTypes.CLOTHINGREL)
private Set<Clothing> clothing;
@Id
private String id;
@Relationship(type = RelationshipTypes.VisitedLocationREL)
private Set<LocationVisited> LocationVisiteds;
@Relationship(type = RelationshipTypes.CorrespondedLocationREL)
private Set<LocationCorresponded> LocationCorrespondeds;
private String name;
private String gender;
public Person() {
}
public Person(@JsonProperty(value = "id") String id,
@JsonProperty(value = "name") String name,
@JsonProperty(value = "gender") List<String> gender,
) {
this.id = id != null ? id : "";
this.name = name != null ? name : "";
this.gender = gender != null ? gender.get(0) : "";
this.clothing = new HashSet<>();
this.LocationVisiteds = new HashSet<>();
this.LocationCorrespondeds = new HashSet<>();
}
public void addClothing(Clothing cloth) {
this.clothing.add(cloth);
}
public void addLocationCorresponded(LocationCorresponded dc) {
this.LocationCorrespondeds.add(dc);
}
public void addLocationVisited(LocationVisited dd) {
this.LocationVisiteds.add(dd);
}
}
@NodeEntity
public abstract class Location extends Entity {
@Id
private String Location;
Location(@JsonProperty(value = "Location") String Location) {
this.Location = Location != null ? Location : "";
}
Location() {
}
public void addPerson(Person person) {
}
}
@NodeEntity(label = "Location")
public class LocationVisited extends Location {
@Relationship(type = RelationshipTypes.VisitedLocationREL, direction = Relationship.INCOMING)
Set<Person> persons;
LocationVisited(@JsonProperty(value = "Location") String Location) {
super(Location);
this.persons = new HashSet<>();
}
LocationVisited() {
}
public void addPerson(Person person) {
this.persons.add(person);
}
}
@NodeEntity(label = "Location")
public class LocationCorresponded extends Location {
@Relationship(type = RelationshipTypes.CorrespondedLocationREL, direction = Relationship.INCOMING)
Set<Person> persons;
LocationCorresponded(@JsonProperty(value = "Location") String Location) {
super(Location);
this.persons = new HashSet<>();
}
LocationCorresponded() {
}
public void addPerson(Person person) {
this.persons.add(person);
}
}