Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Save on entity that links to itself through another entity is often not successful. #85

Open
dijef opened this issue Jan 16, 2019 · 0 comments

Comments

@dijef
Copy link

dijef commented Jan 16, 2019

I have three entity classes: A, B, C.
A contains list of B (OneToMany, Lazy)
B contains A (ManyToOne, lazy)
B contains list of C (OneToMany, Lazy)
C contains B (ManyToOne, lazy)
All entities have their POJOs to which they're converted after retrieve.

When retrieving them, ODirtyManager class marks entity being retrieved as dirty when resolving foreign keys. However ODirtyManager is not cleared for retrieved entity. So on next retrieve and an attempt to save same entity often actual save is overriden by older copy of same entity held by ODirityManager (set are used, so I guess that's why outcome is random).

My test do (and refreshes objects after each read):
addBtoA(a, b1);
addBtoA(a, b2);
addCtoB(b1, c1);
addCtoB(b1, c2);
addCtoB(b2, c3);
addCtoB(b2, c4);

and finally sets boolean value on c to true.
setTest(c1, true);

Tests randomly fails at different stages, rarely passes. When using OrientDBObject with same entity classes issue does not happen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant