Session#save(...) 如何识别更改的实体?

How does Session#save(...) identify changed entities?

Neo4j OGM manual 说:

Under the bonnet, the implementation of Session has access to the MappingContext that keeps track of the data that has been loaded from Neo4j during the lifetime of the session. Upon invocation of save() with an entity, it checks the given object graph for changes compared with the data that was loaded from the database. The differences are used to construct a Cypher query that persists the deltas to Neo4j before repopulating it’s [sic] state based on the response from the database server.

这实际上是如何工作的?它取决于实体 类 覆盖 hashCode() 还是什么?

不,OGM 不依赖于 hashCode 的实现。相反,它使用自己的基于 属性 值的散列来检测节点是否已更改。对于关系,MappingContext 保存会话中加载的实体的已知关系集,并且在保存时,该集合与从正在保存的实体收集的关系进行协调。根据添加、修改或删除的关系,增量用于构造发送到 Neo4j 的 Cypher 查询。