Property marked dirty when using custom BindUsing
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
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](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
>
Contributor guide
Research direction
Start with the linked reproducer and the shown dirty-checking test, then compare its custom BindUsing behavior with the Hibernate result described in the issue. Done means binding the same Club leaves player.hasChanged('club') false, while the regression test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100