Skip to content

Domain classes marked as dirty without changes on them #1307

@Tirla-Alin

Description

@Tirla-Alin

Domain classes are marked as dirty when any operations are done on the grails.web.databinding.WebDataBinding#getProperties, without actually changing any property.

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Create a simple grails 4.0.1, gorm 7.0.2.RELEASE (with mongo plugin support) application
  2. Create 2 simple domain classes
    import groovy.transform.AutoClone

    @AutoClone
    class BuggyCard implements Serializable {
        BuggyCardProfile buggyCardProfile
        
        static hasOne = [buggyCardProfile: BuggyCardProfile]
        static constraints = {
            buggyCardProfile nullable: true
        }
    }
class BuggyCardProfile implements Serializable {
    BuggyCard buggyCard
    static constraints = {
        buggyCard nullable: true
    }
}
  1. Insert entities in db
BuggyCard.withNewTransaction {
    def card = new BuggyCard()
    card.save(flush: true, failOnError: true)
    def profile = new BuggyCardProfile()
    profile.buggyCard = card
    profile.save(flush: true, failOnError: true)
}
  1. Create one simple controller with an endpoint.
	@Secured(['IS_AUTHENTICATED_ANONYMOUSLY'])
	def buggyEndpoint() {
                 // todo replace this with the id of the created buggyCard from step 3
		def buggyCard = BuggyCard.findById(1)
		def set = buggyCard.properties.entrySet()
		log.info("is dirty? " + buggyCard.isDirty())

		return respond("result": "result")
	}
  1. Notice that the entity is dirty.

Expected Behaviour

Domain classes should not become dirty without actual changes on them.

Actual Behaviour

Domain classes are marked as dirty without actual changes on them.

Environment Information

  • Operating System: macOS Catalina 10.15.4
  • Grails Version: 4.0.1
  • JDK Version: 1.8.0_231
  • Container Version (If Applicable): N/A

Example Application

  • TODO: link to github repository with example that reproduces the issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions