[odb-users] Brief-case model with ODB

Boris Kolpackov boris at codesynthesis.com
Mon May 7 04:38:14 EDT 2012


Hi Alexander,

Alexander Konin <aakmail at mail.ru> writes:

> How about brief-case model with ODB? Typical use case of an application 
> I designing looks like this: a user connects to database with his personal
> notebook and retrieves neccessary data. Then the user saves the data on
> local storage (notebook HDD) and close the application (turns off the
> notebook). Next time, for instance at home, the user works with the data.
> Then the user must synchronize his work with database.
> 
> IMHO, simplest way to implement this scenario is serialisation of the
> odb::session object to any local storage (like XML or binary file),
> but there is no any related functionality in the odb::session class.
> Are there other solutions for this scenario with ODB?

To me, saving the data to a local relational database (e.g., SQLite)
sounds like the most natural way to support this. This way, most of
the application logic won't need to know whether it is working with
a local or remote database.

The catch here is that ODB doesn't yet have multi-database support (
i.e., the ability to store the same object to multiple database
implementations from the same application). But this support is coming
soon.

Serializing objects to a binary or XML format will probably work as well.
I agree, currently, there is no way to iterate over the objects in the
session. While we can easily add this support, I am not sure it will
be very usable. If you look at the data members in the odb::session
class, you will see that the objects are stored in a typeless form
(all you have to identify what kind of object it is is std::type_info).

In that sense, it might be easier to derive all your objects from a
common base class and then use a callback (see Section 12.1.7) to
insert all the objects into a custom map.

But if you think that the ability to iterate over a session will be
helpful, let me know, and I we will add it.

Boris



More information about the odb-users mailing list