orientechnologies / spring-data-orientdb

OrientDB implementation for SpringData

Home Page:http://forum.springsource.org/showthread.php?99627-OrientDB-support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dijef opened this issue · comments

commented

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.