Hi all,
I've been using neo4j for awihle now but just started taking advantage of the awesome ogm java library. Ive been struggling over an issue for the past couple days and I cannot for the life of me figure it out. I've finally decided to break down and seek advice.
Using the Neo4j OGM library, I'm converting json documents into POJOs into Nodes / Relationships. I have nodes with multiple relationships. These connections are many to many.
It was working great until I realized I need RelationshipEntities to be uniquely identified so they are not duplicated. So I decided to use an implementation of IdStrategy to uniquely identify these relationships.
The strategy hashes on unique strings from the start and end node.
public class IdGenerator implements IdStrategy {
@Override
public Long generateId(Object o) {
return Hashing.sha256()
.newHasher()
.putString(o.toString(), Charsets.UTF_8)
.hash().asLong();
}
}
@RelationshipEntity(label="Relationship")
public class Relationship implements Entity {
@Id @GeneratedValue(strategy = IdGenerator.class)
private Long id;
...
}
This throws: Cannot merge node using null property for id
when executing the following:
DEBUG o.n.o.d.bolt.request.BoltRequest - Request: UNWIND {rows} as row MERGE (n:
Query{id: row.props.id}) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, {type} as type with params ...
I hope this is enough information, please ask for more if necessary and I will do my best to elaborate.
Any help is greatly appreciated.