You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "sbglasius (via GitHub)" <gi...@apache.org> on 2026/01/30 08:12:17 UTC

[I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

sbglasius opened a new issue, #15363:
URL: https://github.com/apache/grails-core/issues/15363

   ### Expected Behavior
   
   That all properties, also those who implement an abstract setter, are marked dirty when the property changes.
   
   
   
   ### Actual Behaviour
   
   If a property implements an abstract setter from an abstract class, then it is not marked dirty when changed.
   
   ### Steps To Reproduce
   
   From the accached project's README:
   
   ## Issue description
   
   When a domain class, extending from an abstract class, and this abstract class has  `setFoo()` and getFoo() methods, and the domain class has a property `foo`, then the generated bytecode does not have a `markDirty` call for the property. Other properties not mentioned in the abstract class does have `markDirty` in the bytecode. 
   
   This behavior is not visible in Unit test, but in Integration test and production.
   
   ## Steps to reproduce
   
   Run the test suite. One test `UsingAbstractIntegrationSpec` will fail. 
   
   To debug, add the debug compile options in `build.gradle` and run the test.
   
   ## Identified reason for this behavior
   
   As far as I can tell, `org.grails.compiler.gorm.DirtyCheckingTransformer.addDirtyCheckingSetter()` is not calling `org.grails.compiler.gorm.DirtyCheckingTransformer.createMarkDirtyMethodCall` because in line #316 the `setter` node is not-null, as it is picked up from the abstract class. 
   
   I think it will be fixable just by adding a check for `setter == null || setter.isAbstrct()`  in line #316, but since this is for GORM 8.1.2 (And Grails 6.2.3), I am not sure if 1) This is the right approach, and 2) If it is, how can I get it released?
   
   
   ### Environment Information
   
   Ubuntu (but irrelevant) 
   Java 17
   Grails 6.2.3 (I am about to add a branch that checks Grails 7 as well)
   
   ### Example Application
   
   https://github.com/sbglasius/grails-gorm-abstract-setter-issue
   
   ### Version
   
   6.2.3 and most likely 7.0.x as well


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-3824163343

   I suggest we dismiss this ticket and update the documentation per https://github.com/apache/grails-core/issues/14185 since this isn't a bug.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-3824132363

   This was an intentional change in gorm 6.1.  https://grails.apache.org/docs-legacy-gorm/6.1.x/hibernate/manual/index.html#_dirty_checking_for_abstract_base_classes 
   
   There is an open ticket how this was never added to the documentation (only the original upgrade notes): https://github.com/apache/grails-core/issues/14185


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-3836068397

   @sbglasius the setter/getter find is definitely a bug.  I agree that needs fixed to be treated like a property.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-3831865901

   I disagree. Having abstract setters still show the described behaviour


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-3822481260

   Same issue can be found in Grails 7.0.x (branch 7.0.x in the attached example application)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-3824118946

   Add `@DirtyCheck` to the abstract class and it will work.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] GORM property implementing setter from abstract class does not get marked dirty [grails-core]

Posted by "hk2166 (via GitHub) via notifications" <no...@grails.apache.org>.
hk2166 commented on issue #15363:
URL: https://github.com/apache/grails-core/issues/15363#issuecomment-6765046850

   I'd like to work on this, the setter part @jdaugherty confirmed as a bug. It's the same on 7.0.x and 8.0.x.
   
   `DirtyCheckingTransformer.addDirtyCheckingSetter` looks the setter up with `classNode.getMethod(setterName, setterParameter)`, which also searches the superclasses. When the abstract class declares `abstract void setFoo(String foo)`, it finds that method, so it doesn't add the `setFoo` that calls `markDirty('foo', foo)`. Groovy then generates its plain setter for the `foo` property, which implements the abstract one and records nothing, so `isDirty('foo')` stays `false`. The getter lookup a few lines above has the same shape. The domain class's other properties aren't affected, which matches the attached example.
   
   My plan, against 7.0.x unless you'd prefer another branch:
   
   1. Treat a setter or getter that is abstract, or that the domain class doesn't declare itself, as missing, so the transformer adds its own dirty-checking accessor that overrides it. A setter the domain class writes itself keeps being woven into as it is today.
   2. Add a spec in `grails-datamapping-core` for a domain class that extends an abstract class with abstract `getFoo()`/`setFoo()`, through an interface too, checking that the generated setter marks the property dirty. Add a Hibernate 5 spec showing that the change to such a property is saved, as in `UsingAbstractIntegrationSpec` from the example.
   3. Check that adding `@DirtyCheck` to the abstract class, the documented route, behaves as before.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org