I'm currently working on a project with spring-data-neo4j (current release) and I'm facing a problem when trying to merge two classes and their properties into one NodeEntity. Here are my two classes:
@NodeEntity(label = "entity")
public class Ent1 {
@Id
@Index(unique = true)
private Integer id;
private Integer data1;
}
.
@NodeEntity(label = "entity")
public class Ent2 {
@Id
@Index(unique = true)
private Integer id;
private Integer data2;
}
By defining the id property annotated with @Index, SDN is doing merges instead of inserting multiple nodes with the same index.
What I want to achieve is that if I save an instance of Ent1 and afterwards another instance of Ent2 with the same id as the Ent1 entity both data attributes should be present in the resulting node. They should be merged.
In fact either data1 or data2 is present, dependent on which entity has been saved last. Merge doesn't really seem to merge, instead it replaces the entities properties.
Does anyone have a solution for merging all property fields instead of replacing/removing them?