-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entities inside embedded collections don't track changes #148
Comments
Same issues, same fix. Wrote logic to call
I would not expect anything on a freshly pulled domain record to be marked as dirty. And changing anything on an Entity I would expect to mark all parent structures as dirty as well. I did see the note on https://gorm.grails.org/latest/hibernate/manual/index.html#domainClasses under |
Here is an example project:
https://github.com/valentingoebel/grails-dirtycheckingbug/
application.yml requires following env variables so make sure you fill them.
Here is a summary of the code:
Calling
trackChanges()
on each entity inside the embedded list results in the desired outcome. I am already using this workaround in my projects but it required substantial changes in my code because using databinding in controller parameters likedef show(DBList list)
will fill each field before you even get an opportunity to call trackChanges().Even with
trackChanges()
there is still the issue that the list itself does not get marked as dirty. This is fine in the non embedded case because changing an entity would mark all its associated entities dirty which is certainly not what we want but for embedded entities it could make sense because an embedded entity is always contained inside a parent entity. Therefore changing the child could be interpreted as a change in the parent.I only need the first bug fixed because it prevents me from using databinding in controller parameters. The second one is up for discussion and can be rejected if it doesn't make sense. Marking a list dirty when at least one of its elements has changed is very easy so I'm not really insisting on that change.
The text was updated successfully, but these errors were encountered: