Skip to content

Commit 2c12a6d

Browse files
committed
Document GormService changes
1 parent e8d5a8b commit 2c12a6d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

grails-doc/src/en/guide/upgrading/upgrading60x.adoc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
----

0 commit comments

Comments
 (0)