Skip to content
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

Property marked dirty when using custom BindUsing #81

Open
mvinas1977 opened this issue May 10, 2018 · 0 comments
Open

Property marked dirty when using custom BindUsing #81

mvinas1977 opened this issue May 10, 2018 · 0 comments

Comments

@mvinas1977
Copy link

I have this simple model

class Club {

    String name

    static constraints = {
        name nullable: false
    }
}
class Player {

    String name

    @BindUsing({ Player player, SimpleMapDataBindingSource source ->

        if (source['club']?.id) {
            return Club.get(source['club']?.id as Long)
        }
    })
    Club club

    static constraints = {
        name nullable: false
        club nullable: false
    }
}

Player has a custom binding ... if you bind same club it marks club as dirty when it should not. this simple test reproduce the error

   void "test dirty hibernate"() {
        given:
        Club club = Club.findByName('Boca Juniors')
        assert club
        Player player = Player.findByName('Juan Roman Riquelme')
        assert player

        when:
        player.properties = [club: [id: club.id]]

        then:
        !player.hasChanged('club')
    }

Same code works fine with hibernate

I shared a proyect with this example app to reproduce this error https://github.com/mvinas1977/gorm-proxy-dirty-property-issue

I'm using the following versions

grailsVersion=3.3.5
gormVersion=6.1.10.BUILD-SNAPSHOT
grailsNeo4jPluginVersion=6.2.0.BUILD-SNAPSHOT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant