apache / apache/grails-core

Dynamic Update for domain objects that extend a parent, do a full update of both.

Open
#14,454 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-data-hibernate5
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Steps to Reproduce

1. Run the sample application
2. hit the following urls and note the sql output on the console on each url.

- http://localhost:8080/test/create_child
- http://localhost:8080/test/update_a
- http://localhost:8080/test/create_parent
- http://localhost:8080/test/update_parent

This creates a child object and updates one of it's properties, and create a parent and updates one of its properties.

There are also urls for updating the parents property through the child:
http://localhost:8080/test/update_p

and updating both a child and parent property through the child:
http://localhost:8080/test/update_ap

The extra urls are so that you can see the output of the various scenarios. I also tried using the @DynamicUpdate hibernate annotations but those don't seem to work either. Normally I also wouldn't put the logic in the controller, but this is just to create a quick app to debug.

### Expected Behaviour
When you have dynamic update set on a parent and child domain object, updating one of the child's properties should result in sql that only updates the child's property, and not the parents. When updating the parents properties alone, then the only the parent will be updated, and only the properties changed.

### Actual Behaviour
When you have dynamic update set on a parent and child domain object, updates to the the child object, do a full update of both the parent and child object. When updating just the parent domain object only the properties that have changed are updated.

### Environment Information

macOS 10.14.4 (18E226)
Grails 3.3.9
java version "1.8.0_171"

### Example Application

https://github.com/virtualdogbert/dynamicUpdate

Contributor guide

Open the contributing guide

Research direction

Start with the linked dynamicUpdate example application and run the listed create and update URLs while watching the SQL output. Compare child, parent, and through-child updates with the expected behavior: only changed properties and the affected object should be updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.