[odb-users] odb persistence in a library / cross-model
christian at gsvitec.com
Thu Oct 1 11:50:29 EDT 2015
I have looked into this further and added "cross-model dependencies" to the
subject line of this mail because I think that is what this problem boils down
to. Since I found no solution in the ODB manual, I decided to run an experiment
to determine the technical feasibility.
Note that I am using pragma-only files, no #pragma markup in normal source
files. What I did is this:
- first compile the library, with Class1, Class2 and Class3 declared and mapped
- then compile libraryuser, with mappings for Class1 and Class4
- then go to the libraryuser generated source files and remove the Class1 code
section. Also remove the CREATE/DROP TABLE for Class1
now I ran my libraryuser application, which first lets the library run its
database creation code, and then runs its own. Everything works well, I was able
to add Class4 instances to the Class3::poly_container and load them again. So,
there seems to be no fundamental issue with my approach.
My Question: are cross-model references really unsupported or did I miss
something? If they are unsupported, could that be changed? My idea would be
something like a "#pragma db object polymorphic external" where the "external"
part would tell ODB the given mapping is already present in another model.
> Christian Sell <christian at gsvitec.com> hat am 30. September 2015 um 18:44
> still working on the "persistence in library" subject. Here's a problem I
> encountered during my first test run:
> we have an abstract, polymorphic superclass that is mapped inside the library.
> Now we want to allow the user of the library to extend the object model by
> adding new subclasses, which should also be made persistent AND be accessible
> through the same polymorphic relationship. Graphically:
> Class1 polymorphic
> Class2 extends Class1
> vector<Class1> poly_container
> Class4 extends Class1
> this immediately fails during odb compilation of the LibraryUser files,
> odb complains that Class4 does not designate an object id. The reason is
> - odb doesn't know that Class1 has been mapped polymorphically elsewhere. Can
> this situation be solved somehow?
GS Vitec GmbH
Im Ziegelhaus 6-8
mail: christian at gsvitec.com
mobil: +49 (0) 173 5384289
Tel: +49 (0) 6051 601.26-90
Fax: +49 (0) 6051 601.26-91
More information about the odb-users