How to use the merge option in spring data neo4j entity objects rather than using CQL @Query .
I think SDN repositories use MERGE by default for save operations.
Yes its by default. By using SDN we might have to fetch the required entity or node from neo4j db and
then update as required and save the entire entity, but the fetching part from neo4j db might be a costly call when the number of requests increases. So is there any way to avoid this fetch and allow SDN to handle merge if present and create a new node if not present ?
At the repository abstraction level, you already have a few options:
- custom queries via @Query
- custom repository implementation (aka repository fragments)
Whether you're using fragments or not, you are free to rely on the lower-level abstractions provided by Neo4jTemplate
and Neo4jClient
.
I believe you can achieve what you want with either of these options.