[odb-users] Persist Google's Protocol Buffers...

Boris Kolpackov boris at codesynthesis.com
Mon Jan 27 23:32:43 EST 2014


Hi Alon,

Alon Moshayov <alon.moshayov at myheritage.com> writes:

> I'm looking for an ability to persist Google's Protocol Buffers with
> ODB to SQLite database.
> Does ODB capable to accept protocol classes and generate corresponding
> database support code?

I believe several people tried this and it is possible. You will need
to map the generated protobuffer classes for ODB. That is, specify
which classes are persistent, what are their ids, etc. This can be
done completely unintrusively (so you don't need to modify the
generated files), as described at the beginning of Chapter 14,
"ODB Pragma Language".

Also, the recently added support for automatic discovery of suitable
accessors and modifiers should make this mapping really easy. In most
cases I would expect all you need to do is have two pragmas like these
for each persistent class:

#pragma db object(Foo)
#pragma db member(Foo:id) id

Also, here is a previous thread on the same topic with some more
background information (note that the virtual data members feature
mentioned there is now supported):

http://www.codesynthesis.com/pipermail/odb-users/2011-October/000352.html

Boris



More information about the odb-users mailing list