I have two entities in database, Category and Subcategory. Category can have multiple subcategories. The relationships are defined like this:
Category->Subcategories(to-many, has inverse, cascade)
Subcategory->Category(to-one, has inverse, nullify)
It all works ok but sometimes Category->Subcategories relationships is empty and Subcategory->Category is ok, which is weird. This happens very very rarely and I can't figure out the cause.
Below is a log from console in which it can be seen that instance of category has empty Subcategories relationship but one of subcategories in database has that same Category instance as its relationship.
I don't understand how one end of the relationship can be empty and other ok since they are automatically connected when either end is set.
Category: 0x7b6f8020> (entity: Category; id: 0x7b6f6d40 x-coredata://021C3D9A-7A0C-4326-B526-9E9253611C44/Category/p8> ; data: {
… other data
subcategories = (
);
})
Subcategory: 0x7c8f7770> (entity: Subcategory; id: 0x7c8c91b0 x-coredata://021C3D9A-7A0C-4326-B526-9E9253611C44/Subcategory/p5> ; data: {
… other data
category = "0x7b6f6d40 x-coredata://021C3D9A-7A0C-4326-B526-9E9253611C44/Category/p8>";
})