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

Benjamin Schudel benjamin.schudel at nexirius.com
Thu May 23 08:52:21 EDT 2013


Hi Boris

Thank you for the help. We are one step further. Now we stumble over a
compile problem, which somehow seems to be  related to the use of
inheritance of the persisted classes. The Compiler complains of a missing
static member 'table_name' within our abstract base class (BaseBO).

We have tried to overcome this problem by simply adding the static char[]
table_name member into the generated BaseBO class, which had the effect,
that at least the compiler did not complain anymore.

Class BaseBO-odb-mssql.hxx

template <typename A>
  const typename query_columns< ::BaseBO, id_mssql, A >::id_type_
  query_columns< ::BaseBO, id_mssql, A >::
  id (query_columns< ::BaseBO, id_common, typename A::common_traits >::id,
      A::table_name, "[id]", 0, 1);
error C2039: 'table_name' : is not a member of
'odb::access::object_traits_impl<BaseBO,id_mssql>'
(ODBGenerated\BaseBO-odb-mssql.cxx)

Now with this manipulated/patched code, we have tried to start the
application and we ran into the next problem (same as the one I have written
with my previous mail):
exception -> Unhandled exception at 0x0033FE4B in Gui.exe: 0xC0000005:
Access violation reading location 0x00000000.

Stack when the exception occurs as soon as we do our first ODB query (trying
to load the user data):
	Gui.exe!odb::access::object_traits_impl<User,5>::query(odb::database & db,
const odb::query_base & q) Line 93	C++
 	Gui.exe!odb::database::query_<User,5,0>::call<odb::query<User,odb::query_base>>(odb::database
& db, const odb::query<User,odb::query_base> & q) Line 115C++
	Gui.exe!odb::database::query<User>(const
odb::query<User,odb::query_base>& q, bool cache) Line 18	C++
	Gui.exe!UserManager::authenticateUser(QString username, QString
password)Line 77	C++ 	Gui.exe!LoginForm::onLoginClicked() Line
58	C++Somehow it seems like the generated Class User-odb.ixx tries to
access afunction in a function table, which was not initialized
(segmentation fault).inline  result< access::object_traits_impl<
::User, id_common >::object_type >  access::object_traits_impl<
::User, id_common >::  query (database& db, const query_base_type& q)
{    return function_table[db.id ()]->query (db, q); // Segmentation
fault onthis line (the function table array contains 4 null pointers,
I guess it hasnever been initialized correctly?)  }Did we miss out a
statement, which initializes the function table? Is theprocess of
generating a database instance somehow different in the
dynamicmode?Thanks for your helpBenjamin-----Ursprüngliche
Nachricht-----Von: Boris Kolpackov
[mailto:boris at codesynthesis.com]Gesendet: Dienstag, 21. Mai 2013
16:04An: Benjamin SchudelCc: odb-users at codesynthesis.comBetreff: Re:
[odb-users] Multi-Database Support - Cannot integrateMulti-Database
Support / Bug report for the compiler: odb-2.2.1-i686-windowsHi
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 inodb-examples. The difficulty here is that one may want to
build such anapplication with different combinations of databases. For
some buildsystems, e.g. Visual Studio projects, this is hard to
support.However, the manual has two parts that describe multi-database
support in avery hands-on fashion (we intentionally included a lot of
examples in themanual since we don't have a complete example for this
feature).The first part is Section 2.9, "Working with Multiple
Databases" in Chapter2, "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 muchgreater 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 generatingany
"implementations" for specific databases (e.g., mysql, sqlite, etc).I
am pretty sure if you add the corresponding -d options (e.g., -d
mysql, -dsqlite, etc.), and compile and link all the generated file
into yourapplication (i.e., *-odb-mysql.cxx, *-odb-sqlite.cxx, etc.),
then everythingwill just work.In fact, I am surprised that you missed
these options since they are shownand discussed a lot in the manual,
in both parts, and right from thebeginning.> -          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 whatUser-odb.hxx would contain.
Again, this is discussed in detail in the manualand I am surprised you
missed it. Perhaps you should re-read Chapter 14completely again to
gain better understanding of how multi- database supportworks in
ODB.Boris



More information about the odb-users mailing list