[odb-users] odb persistence in a library / cross-model dependencies

Boris Kolpackov boris at codesynthesis.com
Mon Oct 5 12:21:30 EDT 2015


Hi Christian,

Christian Sell <christian at gsvitec.com> writes:

> > What exactly does "cross-model references" mean, anyway?
> 
> in essence, in this case it means that a class from one model wants to
> subclass a class from another model. the same would go for relationships,
> pointers and the like.

Ok, in ODB, you cannot change the id column of an object in any way
other than by creating a new class. And polymorphic inheritance,
underneath, is a essentially a relationship. So all this is not an
issue when schema evolution is concerned except for one case: you
can remove a class, be it a base class or a pointed-to class.

So imagine a situation where you have the base class in one "schema"
(e.g., your application) and a derived class in another (e.g., your
extension library). Then you go ahead and remove the base class. ODB
has no support for detecting or handling this case. But then, again,
neither does C++ ;-)


> Again: [...]

Seeing that you are using mapping headers, you can use the 'definition'
pragma to control what schema gets generated where:

// lib_pragmas.h
//
#include <ClassA.hpp>
#include <ClassB.hpp>
#pragma db object(ClassA) ypolymorphic
#pragma db member(ClassA::number) id
#pragma db object(ClassB)

#ifdef LIB_SCHEMA
#pragma db object(ClassA) definition
#pragma db object(ClassB) definition
#endif

// app_pragmas.h
//
#include <lib_pragmas.h>
#include <ClassC.hpp>
#pragma db object(ClassC) definition

odb ... -DLIB_SCHEMA --schema-name lib lib_pragmas.h
odb ...              --schema-name app app_pragmas.h

Boris



More information about the odb-users mailing list