Reputation: 5391
I would like to update lastUpdate
field in node each time some property is change.
Is there is some general solution for it from Neo4j level or Spring Data?
The problem is that our structure and code exsist and these feature has to be added. We use in application Spring Data (ver. 3.1.1) with Aspects. As I see it now I have to change:
save()
method from GraphRepository
persist()
from nodeI wonder if there is some simpler method that these steps.
Upvotes: 2
Views: 969
Reputation: 39925
You can use a TransactionEventHandler
. In your case use the beforeCommit
method, iterate over the the changed properties in that transaction using TransactionData.assignedNodeProperties()
and set the lastUpdate
on the given to current timestamp.
TransactionEventHandler are a sharp tool, be very careful to keep the impact as small as possible.
Upvotes: 1