-
Notifications
You must be signed in to change notification settings - Fork 350
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
Only delete those referenced entities that are no longer present in an aggregate. Use an upsert for all others [DATAJDBC-224] #450
Comments
Tyler K Van Gorder commented I have implemented this is a past life by:
There is one "gotcha" with step 3: If the list of referenced entities is above a certain threshold (and its database dependent) then your in-clause will have too many values. I remember Oracle complaining when the number of values exceeded 1000. You can work around this by ordering the list of in-memory Ids, using a batch size (say 100 elements?) and bounding your delete by the first and last values of each batch:
This works if your IDs are numbers...I think it would also work for IDs that were strings, so long as your ordering algorithm in Java matches that of the database |
clgraf commented I don't know if is it ok to ask this question here, but I really don't understand yet how the process works... this issue is really important to my project and I realized it is on the sprint right now... so It would be released soon? |
Jens Schauder commented Hi clgraf, sorry the sprint information was misleading. For Neumann we are busy with some changes that will break some API (nothing to drastic, but still). Since the changes break the API they must all go into Neumann and this issue isn't one of it, so it is more likely to come in Neumann+1 |
I think that the 1 st option must be default behavior or may be switched on by some annotation on Aggregate Root.
|
When updating an aggregate we should not delete all referenced entities in the database.
Instead we should only delete those no longer present in the database and use an upsert/merge on the others.
There are a couple of things to watch out for.
in ( ... )
might not work. We need to figure out how we might construct an equivalent statement for the supported databases.This is a subtask of #437
Jens Schauder opened this as DATAJDBC-224
The text was updated successfully, but these errors were encountered: