Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-15-2021 09:19 AM
I user spring-boot-starter-data-neo4j version 2.4.5
If I try to delete a Pojo like this:
pojoRepository.deleteById(pojo.getCompletePath());
The pojo is deleted but the attributes still exist. Shouldnt the attributes get deleted together with the pojo?
Something similar happens if I try to update the pojo with save:
var pojo = pojoRepository.findById(completePath);
pojo.setAttributes(Collections.emptySet());
pojoRepository.save(pojo);
If I do this the pojo itself is updated and is not related anymore to the attributes, but the attributes still exist as nodes.
My PojoNode looks like this:
@Node
public class Pojo {
private boolean emptyHull;
@Id
private String completePath;
private String className;
private Package aPackage;
@Version
private Long version;
@Relationship(type = "attributes")
private Set<Attribute> attributes = Collections.emptySet();
@Relationship(type = "parent")
private Pojo parentClass;
@Relationship(type = "interfaces")
private Set<String> interfaces = Collections.emptySet();
My AttributeNode looks like this:
@Node
public class Attribute {
@Id
private String id;
@Version
private Long version;
private String name;
private String accessModifier;
//isOnlySet if the class is of type java.util.list
private Pojo genericType;
@Relationship("DeclaringClass")
private Pojo clazz;
I thought maybe it is supposed to work like this because an Attribute Node still has other relationsships after it was deleted or maybe I need to set the relationship direction in some way for sdn to understand that I want it to delete all Attributes of an pojo if I delete a pojo.
Solved! Go to Solution.
05-17-2021 08:03 AM
There is at the moment no support for cascading deletes in Spring Data Neo4j. One of the reasons is that often SDN-based applications are not the only consumers of the database and we cannot foresee the impact an implicit delete on a node might have.
In those cases you would have to manually delete the previously attached nodes.
05-17-2021 08:03 AM
There is at the moment no support for cascading deletes in Spring Data Neo4j. One of the reasons is that often SDN-based applications are not the only consumers of the database and we cannot foresee the impact an implicit delete on a node might have.
In those cases you would have to manually delete the previously attached nodes.
All the sessions of the conference are now available online