-
Notifications
You must be signed in to change notification settings - Fork 169
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
Binder: Add method to write only the changed properties to the bean #18583
Comments
I think we should avoid the boolean parameter since you never remember what The difference between 1. and 3. is mostly about implementation effort. 1. is less to implement (and document and test) but 3. is certainly more powerful. 1. is forward compatible which means that we can start with 1. today and then we still have the option to extend that to 3. at any point in the future without breaking changes. One small additional suggestion to 3. is that |
On naming: I can see that |
I think the distinction is relatively compatible with what I expect to be common mental models. "Overwrite" and "incremental update" are established concepts whereas "overupdate" and "incremental write" are not. At the same time, a more explicit name might also be useful. |
I'd go with the option 3 but probably without new Set<Binding<BEAN, ?>> getChangedBindings() {
return changedBindings;
}
public void writeBean(BEAN bean) throws ValidationException {
writeBean(bean, bindings);
}
public void writeBean(BEAN bean, Set<Binding<BEAN, ?>> bindingsToWrite) throws ValidationException {
BinderValidationStatus<BEAN> status = doWriteIfValid(bean, bindingsToWrite);
if (status.hasErrors()) {
throw new ValidationException(status.getFieldValidationErrors(),
status.getBeanValidationErrors());
}
}
// usage example:
writeBean(bean, getChangedBindings()); |
Hopefully the |
It is not uncommon that setters of the bean may have side effects that application developer would not like to get triggered when writing bean with value which is not changed. E.g. This is how jOOQ tracks changes on records and will then generate minimal update statements.
Current implementation is
updateBean
.
Unfortunately
changedBindings
is private and you can just extend BinderThis would allow greater flexibility to write any subset of bindings for other edge cases i am not able to figure out now. Having getter for
changedBindings
could also serve other purposes (see also #15266).What you would vote for 1., 2. or 3.?
The text was updated successfully, but these errors were encountered: