[odb-users] How to persist cyclic pointers among A->B->C->A?

Boris Kolpackov boris at codesynthesis.com
Mon Oct 14 09:34:21 EDT 2019


Justin Huang <yohuang at nvidia.com> writes:

> If I have three classes A, B and C, and A has pointer to object of class B,
> B has pointer to object of C, and C has pointer to object of A, which is a
> cyclic pointer relationship.
> 
> How should I persist objects a1/a2/b1/c1? E.g., the persistent sequence,
> and how to avoid persist same objects twice?

You can persist them in any order (within the same transaction) provided
their ids have been assigned (which could be problematic if you use auto-
assigned ids).

You will also have to somehow make sure you are not persising the same
object twice. One way would be to use the session (object cache) and
check if each object is already there before persisting it:

https://codesynthesis.com/products/odb/doc/manual.xhtml#11



More information about the odb-users mailing list