I use the SDN 3.0.0 in production (I know this isn't the last version).
Basically, I have a `Parent` class (@NodeEntity) having a relationship
(Set[Child]) to its children, without no declared @Fetch on it.
When I want to update the parent, I do:
1. Find the parent to update through the repository (findById)
2. Clear the current Children collection (to avoid the entry added when
having no @Fetch on the collection)
3. Use a custom repository method to retrieve its current children =>
@Query("MATCH (p:Parent {id: {0}})-[:HAVE]-(child) RETURN child")
4. Add all children to the parent's collection + new
children (parent.addAll(children)) or other properties's values
5. save the parent
*The issue comes in step 3*: the retrieved collection is *empty* ! I'm
pointing out that I'm using the simple mapping mode with REST mode, so i
don't understand, why the clear() method impacts its result. I think that
the simple mapping mode makes a copy of the object so it's detached.
Indeed, I find this workaround:
1. Find the parent to update through the repository (findById)
2. Use a custom repository method to retrieve its current children *and
save them in a temporary variable*
3. Clear the current Children collection (to avoid the entry added when
having no @Fetch on the collection)
4. Add all children to the parent's collection* by using the temporary
variable that kept the children* + new children (explaining the
necessity of an update)
5. save the parent
Here, retrieving the current children BEFORE the parent.children.clear()
make the whole work as expected.
My question is: What is the link between a clear() on a relationship, and
a Cypher query (through SDN-style repository). The first impacting the
other.
Thanks,
Michael
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.