-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Parent Child delete not working with ConcurrentModificationException - tried diff ways #899
Comments
Hello, for (int i = cars.size() - 1; i >= 0; i--) {
Car car = cars.get(i);
List<Tire> tires = car.getTires();
for (int j = tires.size() - 1; j >= 0; j--) {
tires.get(j).removeFromRealm();
}
} |
First of all, thanks a lot for the almost immediate response. |
That's a controversial issue since there is no right way to handle cascading deletes. For example, imagine you have a Developer class and an Issue class. A developer can be assigned to several issues. So we need to be able to support all use cases and the current state, while vastly sub-optimal, is at least flexible enough to handle all the use-cases we came across so far. |
@emanuelez Agreed. No doubt, but it should be configurable through an annotation at least? I am thinking that there would be more parent/child relationship where the Child makes no sense without a parent than the other way(for e.g. like the one you are mentioning). In all those cases, it would be super useful to just blow the whole thing away in one method call. |
The suggested alternative is a pretty slow operation as you can tell. I have a car which has 4 tires. To delete 10000 cars(4 tires each) takes about 13 seconds, which is unacceptable even on a background operation. I can see several applications performing background syncs where wiping data and recreating them is pretty common. Before you guys address the cascade issue, can we have an interim solution to delete all the children in one shot? Something like a removeAllFromRealm() on a list. This is my current code, is there a better way to do it?
|
@cmelchior Has there been any movement on this issue? Thanks. |
@emanuelez is there any progress on this issue ? It's a sort of critical issue for my case. |
@emanuelez any timeframe for this? As @osayilgan already said this is kind of critical functionality (also for me) |
Bump. Any update on this? |
Yes, we now have the functionality we needed from the core so we can now implement it in the binding |
do we have it now? |
This issue can be splitted in two major parts:
|
As @emanuelez says, this issue is already covered by #1104 and #640. So i'll close this as an duplicate. |
Simple relationship - Car has 1 or more tires. Using version 0.79.1. Due to the absence of cascade delete support, I am trying to delete the children before deleting the parent object(as part of the result collection).
In all cases, I get the same exception. Can you guys tell me how I am supposed to handle this? Cascade delete would be perfect, I just would love to save RealmResult.clear(). Without that, how do I delete the parent and the children. Thanks in advance.
Option 1:
Option 2:
Option 3:
The text was updated successfully, but these errors were encountered: