How To Merge Instead of Create With Neo4jTemplate

前端 未结 1 1041
情书的邮戳
情书的邮戳 2021-01-16 18:00

I\'m currently iterating over an array where each index contains two nodes and a relationship (Part_1 -> Part_2), and I\'m using the Neo4jTemplate.save() method to persist i

相关标签:
1条回答
  • 2021-01-16 18:35

    It's hard to suggest what to change without seeing your code, but it sounds like you're saving new entity instances every time.

    The entity passed to Neo4jTemplate.save(entity) should be updated with an ID once it's been written to the database. SDN will try to update nodes that already have an ID so I'd suggest re-using entity instances instead of creating new ones.

    If you don't want to manage these entities yourself, you could attempt to load entities in step 1 and then only create them if they don't already exist.

    0 讨论(0)
提交回复
热议问题