Closed fedpet closed 3 months ago
This is expected as calling save
once inserts the object, the second call yields an update
as the identifier is populated.
We do not track dirty state and we do not insert null
fields. For the update case, we must provide null
values to the update to reflect the entity state in the database as we do not track any changes.
Another aspect here is that we do only retrieve the generated identifier. Any default values that come from the database aren't transmitted back by the insert
statement. So if you generate values in your database and want to see these, then load-after-save is the only viable approach.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
this code
behaves the expected way, while this one:
will generate an update query that tries to set all fields, even untouched null fields.
So imagine you have a
COLUMN c NOT NULL DEFAULT 'bla'
. The first example will correctly leave c to default since it's never touched. Se second example will unexpectedly try to update c and set it to null, and the DB will throw an exception.