java-object-mapper icon indicating copy to clipboard operation
java-object-mapper copied to clipboard

Handle object graph circularities (A->B->A)

Open roimenashe opened this issue 3 years ago • 0 comments

At the moment, if this was loaded from the database using non-lazy references, it would load the second A as a different instance of A, say A'. It would then load B as B', so instead of creating an object graph with circularities (A->B->A), it would create A->B->A'>B'>A''>B''>A'''…. This would result in a stack overflow or OOM

Be careful of an object A which has 2 references, 1 which references B lazily, the other which references C which references B (non-lazy). So A->B(Lazy) and A->C->B. In this case B should end up as a fully hydrated in both instances, not lazy in both instances.

The same applies to A->B(Lazy) if there also is A->B.

roimenashe avatar Jun 05 '21 17:06 roimenashe