-
-
Notifications
You must be signed in to change notification settings - Fork 261
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 support for JSON bean mutation detection via HASH and SOURCE of JSON string content #2274
Conversation
- MD5 of json content stored on EntityBeanIntercept for dirty detection - Only convert to JSON once (at dirty detection time). Store this json content on EntityBeanIntercept to later push to ScalarTypeJsonObjectMapper for bind Should consider alternative to extend BeanProperty rather than have these if blocks.
@rPraml ... maybe have a look at this and see what you think. Cheers, Rob. |
Hello Rob, I did a very quick (= 5 minutes) look at this. (Will take a detailed look at this next week) Note, we have the second use case, that we need the originalValue / valuePair for tracking the changes in a changelog. Cheers |
Yes @rPraml we can probably work out how to make that an option. With this current PR I think we can try to move some of the logic into the ScalarType (from BeanProperty) so I think there are a couple of adjustments to this. |
Note that we don't need to use readSetIntercept() now as there is no property change listener support
… mutable properties
…json-dirty-detection-md5
…_list_loadedAndNotDirtyAware() BeanState state = DB.getBeanState(found); assertThat(state.getChangedProps()).containsExactlyInAnyOrder("beanList"); // this test fails, because we have a OmList instead of a GenericObject // TODO: Can/Should we enhance the @DbJson/@DbJsonB annotations with a property "dirtyDetection"
…rty / BeanPropertyJsonMapper
Remove scalarType.jsonMapper(value) as we can just use format(value) instead
Plus adjust timing on SqlQueryCancelTest
- Bump ebean-annotation with new @dbjson dirtyDetection and keepSource attributes - Get those to BeanPropertyJsonMapper to chose MutableHash implementation - Modify MD5MutableHash to include check for isDirty() - EBasicJsonList needs keepSource=true to pass that test with oldValue
…e on methods etc)
… is only done once Adds MutableValueInfo.nextDirty() to replace the isEqualToJson() method. The next is computed once and stored. BindablePropertyJsonUpdate makes the .mutableNext(propertyIndex) call to move the next MutableValueInfo and return the json content.
Also adds NoMutationDetection to support NONE
…beanList property @DbJsonB(mutationDetection = HASH) List<PlainBean> beanList;
…known dirty go into beanProperty.checkMutable() As per rPraml's PR and comment Due to handling of mutableNext we need checkMutableProperties() to call into what is now beanProperty.checkMutable() even when we already know it's dirty.
Ok @rPraml I think this is pretty close. Did you want to add any more test cases? |
Expectation is that it is not included in update (still null, no change)
On load:
SOURCE mode supports regenerating the 'oldValue' for change log and persist listeners. It does this by rebuilding the 'oldValue' from the original json source that was stored on EntityBeanIntercept.
Both SOURCE and HASH support BeanState.isDirty() checking.