From c1c9bc4c859f8c22818b124f0b6ea98e8966b4d8 Mon Sep 17 00:00:00 2001 From: Joe McCall Date: Wed, 5 Sep 2018 10:23:12 -0400 Subject: [PATCH] Include autowire configuration for example Newer versions of GORM do not autowire beans by default, so explicitly autowire the security service for the `beforeInsert()` example that uses it. --- .../advancedGORMFeatures/eventsAutoTimestamping.adoc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/src/docs/asciidoc/advancedGORMFeatures/eventsAutoTimestamping.adoc b/docs/src/docs/asciidoc/advancedGORMFeatures/eventsAutoTimestamping.adoc index 9e8b45b7..5cbf1ba9 100644 --- a/docs/src/docs/asciidoc/advancedGORMFeatures/eventsAutoTimestamping.adoc +++ b/docs/src/docs/asciidoc/advancedGORMFeatures/eventsAutoTimestamping.adoc @@ -55,13 +55,19 @@ class Person { static constraints = { lastUpdatedBy nullable: true } - + + static mapping = { + autowire true + } + def beforeUpdate() { lastUpdatedBy = securityService.currentAuthenticatedUsername() } } ---- +Notice the usage of `autowire true` above. This is required for the bean `securityService` to be injected. + ==== The beforeDelete event @@ -382,4 +388,4 @@ autoTimestampEventListener.withoutTimestamps { } ---- -WARNING: Because the timestamp handling is only disabled for the duration of the closure, you must flush the session during the closure execution! \ No newline at end of file +WARNING: Because the timestamp handling is only disabled for the duration of the closure, you must flush the session during the closure execution!