[odb-users] Re: read-only fields

Boris Kolpackov boris at codesynthesis.com
Thu Sep 1 14:17:57 EDT 2011


Hi Viacheslav,

Вячеслав Спиридонов <art at it-gen.net> writes:

> Please can you tell me will be ODB to support read-only fields?

We have actually thought about this but it turns out not so easy to 
implement. Ideally, a read-only member would only be ignored in the
update() call. In particular, it should still be used when we make
the object persistent with the persist() call. This would be similar
to how const members are treated in C++ constructors (i.e., in a
constructor a const member is not considered const).

The difficulty is with ignoring the member for update() but still
passing it for persist(). Right now the update() and persist() 
functionality share what we call an "object image". An image is
basically the object state expressed in database API types. If
an object has read-only members, then we would need two separate
images.

We could probably implement an interim solution where a read-only
member is ignored for both update() and persist(). Would that work
for you?

Boris



More information about the odb-users mailing list