[odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows

Boris Kolpackov boris at codesynthesis.com
Tue May 21 10:04:17 EDT 2013


Hi Benjamin,

Benjamin Schudel <benjamin.schudel at nexirius.com> writes:

> Is there a working example of a Multi-Database support application
> available?

Unfortunately we don't have an example for multi-database support in
odb-examples. The difficulty here is that one may want to build such
an application with different combinations of databases. For some
build systems, e.g. Visual Studio projects, this is hard to support. 

However, the manual has two parts that describe multi-database support
in a very hands-on fashion (we intentionally included a lot of examples
in the manual since we don't have a complete example for this feature).

The first part is Section 2.9, "Working with Multiple Databases" in
Chapter 2, "Hello World Example" which gives a pretty high-level 
overview of (dynamic) multi-database support that should nevertheless
get you going.

The second part is Chapter 14, "Multi-Database Support" which goes
into much greater detail for both static and dynamic support.

 
> -          First I tried to integrate dynamic multi-database support.  For
> that I generated the ODB-Files for my perstistable business objects with
> the following command:
> 
> odb.exe -m dynamic -d common -I C:\Qt\qt-5.0.1-32-dyn\qtbase\include
> --profile qt *.h  (compiler: odb-2.2.1-i686-windows)

Here you only generated the common interface (-d common) without generating
any "implementations" for specific databases (e.g., mysql, sqlite, etc).
I am pretty sure if you add the corresponding -d options (e.g., -d mysql,
-d sqlite, etc.), and compile and link all the generated file into your
application (i.e., *-odb-mysql.cxx, *-odb-sqlite.cxx, etc.), then
everything will just work.

In fact, I am surprised that you missed these options since they are
shown and discussed a lot in the manual, in both parts, and right from
the beginning.

 
> -          In a second step I tried to implement the static multi-database
> support. For that I generated the ODB-Files for my perstistable business
> objects with the following command (sqlite example):
> 
> odb.exe -m static -d sqlite -I C:\Qt\qt-5.0.1-32-dyn\qtbase\include
> --profile qt *.h (compiler: odb-2.2.1-i686-windows)
> 
>        Unfortunately, I realized that the generated source code cannot be
> compiled. Each .cxx file contains an Error. E.g. in the User-odb.sqlite.cxx
> file two includes are on the same line:
> 
>                 #include "UserGroup-odb-sqlite.hxx"
>                 #include "User-odb.hxx"
>
> I think that’s a bug in the compiler, or did I something wrong?

You forgot to generate the common part (-d common option) which is what
User-odb.hxx would contain. Again, this is discussed in detail in the
manual and I am surprised you missed it. Perhaps you should re-read
Chapter 14 completely again to gain better understanding of how multi-
database support works in ODB.

Boris



More information about the odb-users mailing list