-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a way to load POJOs into Records without setting all the changed flags to true #5394
Comments
The change of semantics governs how the following operations work:
At least the following operations will be affected by or may be modified for a semantic shift from
There are special cases which lie in between the two semantics
Operations that will not be affected by the change of semantics:
|
A somewhat similar feature is |
The difficult thing with changing the semantics globally is that while some operations have an available // The record is not attached, so it doesn't have a Settings, meaning that the from() call
// will set the third column to "changed", despite it being null before and after the from() call
TRecord record = new TRecord();
record.from(new TPojo(1, 2, null));
// This call also cannot access any Settings to override the default behaviour of changed(),
// so the third column will have a "null" value being inserted explicitly
Insert insert =
DSL.insertInto(T)
.set(record) In order to apply Besides, even if the operations are lazy, the behaviour of |
For context: A non representative Twitter poll shows that the existing behaviour of Record types is desireable: Setting a value to something means the intent is for that action to have a side effect in the generated query. Good reasons are:
This issue here is about loading POJOs / DTOs into records with |
@lukaseder Maybe related:
It would be nice to have a setting that allows to configure JOOQ to not generate an update statement for columns that do not differ from the originally fetched values. This issue sounds at least like there could be some synergy. If not should I create a new issue for this? |
The question you should ask yourself is, what would a SQL editor do if you "touch" a record? What would a file system do if you "touch" a record? What is the most reasonable intent of "touching" a record? The answer is always the same. It should trigger an update without changing any of the data, because the update signal itself is already useful, e.g. in the presence of triggers. Imagine a trigger that updates a So much for defaults.
I agree a setting could be useful. I'm quite sure there already is an issue, but I cannot seem to find it, so I created a new one: #12494 While there are synergies, I don't think these are the same issues. A POJO has no notion of "changed" flag, so loading a POJO into a record will always set all column values to changed. The issue you're suggesting is to add a new notion of "modified" (or a different name) that is different from the current "changed". "modified" means Perhaps, adding a notion of "modified", and allowing users to prefer using that over the current "changed" flag is a better way to fix what is being requested in this issue here, it might even obsolete this issue, which is purely about loading POJOs into records, an action that may continue to set all "changed" flags to |
Note, some feedback about the expected defaults for inserting/updating unchanged records can be seen here: |
I agree with the reasoning.
👍
Sounds good to me 🙂 I left some feedback regarding terminology and possible configuration options in #12494 |
See also: #2704 |
A lot of jOOQ users don't like the existing default behaviour of setting all
Record.changed()
flags to true when callingRecord.from()
or similar methods. The wanted behaviour is to setchanged()
only to true if the actual value has changed according toObjects.equals()
.This could be achieved in two ways:
Setting
Record
See also:
And earlier discussions:
The text was updated successfully, but these errors were encountered: