Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-06-2021 11:34 AM
I user spring-boot-starter-data-neo4j version 2.4.5
I think it has something to do with the following warning:
Instances of class de.fh.kiel.advancedjava.pojomodel.model.Pojo with an assigned id will always be treated as new without version property!
which always pops up if I try to save anything.
My node:
@Node
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Pojo {
private boolean emptyHull;
@Id
private String completePath;
private String className;
private Package aPackage;
@Relationship(type = "attributes")
private Set<Attribute> attributes;
@Relationship(type = "parent")
private Pojo parentClass;
@Relationship(type = "interfaces")
private Set<String> interfaces;
}
If try to update the node like this:
var pojo = pojoRepository.findById(id);
changeAttributesOfPojo(pojo);
pojoRepository.save(pojo)
it does not update the node.
My ids look like this: de.fh.kiel.advancedjava.pojomodel.exampleData.DefaultClass
They are names names but each name is unique.
I tried to add a version property like this:
@Version
private Long version;
My Application did not work after that. I guess I need to add it differently or need to change my constructurs for that to work. But is the verison property even the problem?
Solved! Go to Solution.
05-06-2021 01:25 PM
Yes, that is right. Because the entity is seen as new, no relationship will be dropped.
But it should create new ones.
I assume that the problem is the missing version
property on the Pojo
nodes now. It has to be set before working with the data because otherwise there would be no chance for SDN to enable the versioning / optimistic locking.
Basically a MATCH (n:Pojo) SET n.version = 0
would be enough to get it running.
05-06-2021 01:25 PM
Yes, that is right. Because the entity is seen as new, no relationship will be dropped.
But it should create new ones.
I assume that the problem is the missing version
property on the Pojo
nodes now. It has to be set before working with the data because otherwise there would be no chance for SDN to enable the versioning / optimistic locking.
Basically a MATCH (n:Pojo) SET n.version = 0
would be enough to get it running.
All the sessions of the conference are now available online