File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
grails-doc/src/en/guide/upgrading Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -860,3 +860,49 @@ The `+` marker is opt-in and fully backward compatible:
860860- Existing URL mappings without the `+` marker continue to work as before (splitting at the first dot)
861861- No changes are required to existing applications
862862- The feature can be adopted incrementally on a per-mapping basis
863+
864+ ===== 12.28 GormService API Changes
865+
866+ The `grails.plugin.scaffolding.GormService` class has been updated to fix a thread-safety issue and improve API clarity.
867+
868+ ====== Changes
869+
870+ 1. The `resource` field type changed from `GormAllOperations<T>` to `Class<T>`
871+ 2. A new `gormStaticApi` field of type `GormAllOperations<T>` was added with thread-safe lazy initialization using `@Lazy`
872+ 3. The constructor no longer instantiates the resource class - it now stores the Class reference directly
873+
874+ ====== Migration Impact
875+
876+ If your code extends `GormService` or accesses its fields:
877+
878+ **Accessing GORM operations**: Previously the `resource` field provided GORM operations. Now use the `gormStaticApi` field instead:
879+
880+ [source,groovy]
881+ ----
882+ // Before (7.1.x and earlier)
883+ class MyService extends GormService<MyDomain> {
884+ void myMethod() {
885+ def result = resource.list() // resource was GormAllOperations<T>
886+ // ...
887+ }
888+ }
889+
890+ // After (7.1.x with fix)
891+ class MyService extends GormService<MyDomain> {
892+ void myMethod() {
893+ def result = gormStaticApi.list() // use gormStaticApi instead
894+ // ...
895+ }
896+ }
897+ ----
898+
899+ **Accessing the domain class**: If you need the Class reference, the `resource` field is now properly typed as `Class<T>`:
900+
901+ [source,groovy]
902+ ----
903+ // Before
904+ Class<MyDomain> clazz = resource.getClass() // awkward, resource was an instance
905+
906+ // After
907+ Class<MyDomain> clazz = resource // resource is now the Class itself
908+ ----
You can’t perform that action at this time.
0 commit comments