[odb-users] Automatically persist / update relations

Boris Kolpackov boris at codesynthesis.com
Tue Sep 22 10:39:15 EDT 2015


Hi Andreas,

Andreas Pasternak MT-Robot AG <a.pasternak at mt-robot.com> writes:

> But I'd like that ODB checks all relations automatically and inserts
> / updates them.

No, ODB doesn't do this. It would be too "magicy" to work reliably and
with a reasonably-good performance. For example, how does ODB know that
the object is not yet persistent? Similarly, how would it know whether
the object has changed (and thus needs to be updated)?

On the other hand, if you make a few application-specific assumptions, 
this should be pretty easy to implement yourself. For example, you can
use 0 as a special "not persistent" object id (auto ids always start
from 1). You can also have a flag that keeps track of whether the object
has changed. The final ingredient is the database operation callback
(Section 14.1.7 in the manual). In it, you can check and update/persist
all the relationships of an object, if necessary.

Boris



More information about the odb-users mailing list