When using bytecode enhancement and @OneToOne with @LazyToOne(value = LazyToOneOption.NO_PROXY) the lazily initialized entities are not tracked properly when set value to null.
The issue happens only when the setter for the entity property is called before the getter for that entity property . In the attached test case, hibernate does not delete content of the setter is comparing between the old attached entity value to the new one , while still persisting and if they are not equal - the new entity value is tracked . This causes errors
if we didn’t fetch the next time value (by calling the getter) - the original value = NULL, and so if we try want to load reset the owning entity, because property value by set NULL - the OneToOne relationship now has two owned entities Objects . If deepEquals in the getter is called before the setter is called, hibernate does delete return true and the old entity property will not be tracked as dirty and will not be updated in DB on the commit .
Test case: see similar issue: [ https:// github hibernate . com atlassian.net / chouze browse / hibernate HHH - test-case-templates 12772|https: / tree / no_proxy_tracking hibernate.atlassian.net/browse/HHH-12772|smart-link] |
|