Closed fpavageau closed 3 years ago
When using DatastoreTemplate.performTransaction() with spring-cloud-gcp-data-datastore 1.2.6.RELEASE, auditing doesn't work for entities.
DatastoreTemplate.performTransaction()
spring-cloud-gcp-data-datastore
1.2.6.RELEASE
That's because the new DatastoreTemplate instance created in performTransaction() does not have the ApplicationEventPublisher of the original one, which is the mechanism by which the AuditingHandler eventually gets called to set the auditing properties.
DatastoreTemplate
performTransaction()
ApplicationEventPublisher
AuditingHandler
I've added a test to DatastoreTemplateAuditingTests in my fork which demonstrates the problem.
DatastoreTemplateAuditingTests
I also have a simple fix ready, if it's actually a bug and you want a PR.
Hi @fpavageau! Thanks for a detailed description, test, and fix! We'll be happy to accept the fix, if you can open a PR!
OK, I've squashed the test commit with the fix commit and opened the PR.
When using
DatastoreTemplate.performTransaction()
withspring-cloud-gcp-data-datastore
1.2.6.RELEASE
, auditing doesn't work for entities.That's because the new
DatastoreTemplate
instance created inperformTransaction()
does not have theApplicationEventPublisher
of the original one, which is the mechanism by which theAuditingHandler
eventually gets called to set the auditing properties.I've added a test to
DatastoreTemplateAuditingTests
in my fork which demonstrates the problem.I also have a simple fix ready, if it's actually a bug and you want a PR.