I am using SDN4 and facing the issue of previous relationships getting deleted on adding new different ones. Here is my scenario,
Step 1 Create a node with some relationships using Relationship entities. save the relationship entity.
Step 2 get the node based on some properties using Spring Repository and Cypher and add new different relationships. Here is my fetch API:
@Component("productRepository")
public interface ProductRepository extends GraphRepository<Product>{
@Query("MATCH (c:Product {uuid:{0}}) RETURN c")
Product findByUuid(String uuid);
}
save the relationship entity
after doing this, the relationships added in step 1 are lost, but those in step 2 persist.
on doing some debugging, i can see that the Node entities returned by a fetch using Cypher and Spring Repository has null value for relationship entity.
Note: If I do not do step 2, then relations in step 1 are reflected correctly.
Could someone please let me know If i am missing something or if this is an issue.I am not seeing a way to specify depth in this case unless this is somewhere in the cypher.
For others reference, I followed Option b as suggested by @Luanne.
here is code snippet
def getByUuid[T](klazz: Class[T], uuid: String): T = {
IterableUtils.getSingleOrNull(session.loadAll(klazz, new Filter("uuid", uuid), 1))
}