[odb-users] Object ID and unidirectional to-one relationships

Boris Kolpackov boris at codesynthesis.com
Mon Jun 27 06:44:43 EDT 2011


Hi Nicolas,

Nicolas ALBEZA <n.albeza at gmail.com> writes:

> The problem is i can't see how to "merge" my two fields (integer id and
> shared_ptr<primary_table_class>) into one.

Yes, I see the issue now. Ideally you should be able to use a pointer
as an object id. However, that would require some extra code to be
generated by the ODB compiler which it currently does not do. I have
added this to the requested feature list so hopefully we will get to
that at some point.

The work-around would be to have the id as an integer and object
pointer as a transient member. You would also need to initialize
one from the other in different situations, e.g., id from pointer
in your constructors and pointer from id after the call to load()).
Having the ability to have a user callback after operations such
as load() would help with the latter case and we plan to add
something like this in the near future.

Boris



More information about the odb-users mailing list