[odb-users] Generating Database Support Code
Boris Kolpackov
boris at codesynthesis.com
Tue Dec 14 10:58:46 EST 2010
Hi Myoungkyu,
I've CC'ed my reply to the odb-users mailing list since others might
have similar questions.
Myoungkyu Song <mksong at vt.edu> writes:
> I wanted to give you some background about my research project.
Thanks, sounds very interesting.
> I was wondering if pragmas is the only means of interfacing with the ODB
> compiler. In our case, we need to add pragmas to the C++ files emitted by
> the X10 to C++ compiler, which may require us to modify the compiler making
> it aware of the persistent classes.
> Is it possible to specify persistent C++ classes using a configuration file
> or an XML deployment descriptor? In other words, even though pragmas are
> pretty straightforward to add, this requires parsing C++ header files, so I
> was wondering if this can be somehow avoided.
Pragmas can be factored out to a separate file which would be more or
less the "mapping" file you are looking for. For instance, the pragmas
in the 'hello' example can be rewritten like this:
// file : hello/person-mapping.hxx
#pragma db object(person)
#pragma db member(person::id_) id auto
In ODB 1.0.0 you would still need to #include this file at the end of
the header file that defines the persistent classes. For example:
// file : hello/person.hxx
...
#ifdef ODB_COMPILER
# include "person-mapping.hxx"
#endif
In the upcoming ODB 1.1.0 the header file can be left unchanged and the
mapping file added to the ODB compilation process with the --odb-prologue
compiler option.
For more information, see Chapter 5, "ODB Pragma Language", particularly
the next on named pragmas:
http://www.codesynthesis.com/products/odb/doc/manual.xhtml#5
> I was also wondering whether it is possible to persist a subset of the
> fields of a persistent class. In other words, is it possible to configure
> ODB in such a way that some of the fields remain transient?
Yes, you can mark any member as transient with the 'transient' pragma.
Again, see the documentation for details.
Boris
More information about the odb-users
mailing list