I have a domain class which extends another groovy class with same name but in different package in a different library.
The problem is when I modify instances on the domain class, it is not marked as dirty & hence changes are not persisted.
I have read that grails 3 release has some enhancements to dirty checking & this could be a bug or I am missing something.
New objects are saved properly without any issues, I have used isDirty() method on modified domain object as well as modified properties & both return false. Objects are attached to the session, confirmed with isAttached().
To reproduce, I created a test project with following code & tried updating the object from default grails views that are generated using scaffolding, but still the changes are not persisted.
Note: I have done similar stuff in Grails 2.4 & it used to work.
Domain class is as follows:
package com.perseus
class Derived extends Base{
static constraints = {
name blank: false, nullable: false
}
}
Base class in src/main/groovy:
package com.perseus
class Base implements Serializable {
private static final long serialVersionUID = 1L
String name
}
Controller
package com.perseus
class DerivedController {
static scaffold = Derived
}
Link to github project.
Isssue: Model is not marked dirty, even if it has been modified. This happens when a model class extends another groovy class.
How to reproduce:
- Run the app.
- Create a new model object (model name is Derived)
- Modify the object using edit view & click Update.
- You will see that modifications are not persisted.