Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello Rob,
we have a chain of related models which references each other: M1-> M2-> M3
We use a Transacton with enabled batch mode (Without batchMode, everything is fine)
When
CascadeType.ALL
is used, everything is fine, if just M1 is saved. (Ebean recognizes, that M3 has to be saved first, then M2 and finally M1). SeetestMultiSave1
But when M3 is saved manually and then M1, ebean recognizes, that M3 is already in batch (but with wrong depth) and will try to save M2, M1 and then M3 in the wrong order. This will not work, if the beans have already an ID, because in this case, no deferred relationship will be creaated by
BindableAssocOne
: SeetestMultiSave2
I could fix this case by modifiying the "alreadyInBatch" check. We have to flush, if the depth in the batch is bigger than the current order (or modify the order of the existing bean/beanHolder in the queue)
But there is one annoying testcase
testMultiSave4
(This was also discovered in our application)In this case, M2->M3 has no cascadeType set. Saving of M3 has no immediate effect, so saving of M1 will always fail, as there is no cascade-relation to M3
Do you think, this is a bug in Ebean or do we use the cascadeTypes in the wrong way?
Cheers
Roland