[odb-users] [Question] Reverse code generation (.h from .sql)

Boris Kolpackov boris at codesynthesis.com
Wed Feb 9 09:43:30 EST 2011


Hi Alexey,

Alexey Afanasyev <aphongka at gmail.com> writes:

> There is one possible scenario implied by ODB - starting development
> with C++ entities. One should create C++ classes (header files) first
> and then generate SQL sentences to create an appropriate DB structure.

Well, that's one approach. The other is to map existing C++ classes
to the existing database schema using various pragmas (e.g., table,
column, type, etc). The 'schema' example shows how to do this.


> But there is another scenario. There might be an existing DB structure
> first and one might want to use ODB against it. So, the question is if
> there is automation of the process of generating C++ entities (header
> files) by existing DB structure. And if not, are there any plans to
> make it?

Yes, we are thinking about adding this support. The tricky part is to
decide whether it should be a once-off or repetitive process. If you
want to keep re-generating C++ classes from the database schema, then
you cannot customize the generated code (e.g., add functions, etc.)
since your changes will be over-written the next time you change the
schema. On the other hand, by themselves the generated classes will
be just data holders, so this is also somewhat limiting. Which scenario
did you have in mind?

Boris



More information about the odb-users mailing list