Skip to content

Non-dirty Domain with @DirtyCheck on Embedded property causes record UPDATE on session flush and transactions #1272

@dbaylerg

Description

@dbaylerg

I have created an example Grails 3.3.11 Application in GitHub that demonstrates the issue. It is configured for a database connection to a MySql database "test" with user "test" and password "test" but can be reconfigured if necessary.

Example Application

https://github.com/dbaylerg/GormIssue

Steps to Reproduce:

  1. Created a Domain "MyDomain" with an embedded property called "myEmbedded"
  2. Created a class call "MyEmbedded" with @DirtyCheck annotation and a single Integer property
  3. Insert a MyDomain record in the database.
  4. Update the MyDomain.myBedded property and update the record.
  5. Flush the session and the UPDATE is written to the DB
  6. Flush the session again and another UPDATE is written to the DB
  7. Flush the session again and yet another UPDATE is written to the DB.

It is important to note that only when the @DirtyCheck annotation is used on the embedded class will the flushing result in the extra UPDATES

Expected Behaviour

No UPDATES are sent to the database.

Actual Behaviour

UPDATES are sent to the database

Environment Information

grailsVersion=3.3.11
gormVersion=6.1.12.RELEASE
gradleWrapperVersion=3.5
java = openjdk:8

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions