From ckokkeng at dso.org.sg Sat May 4 12:37:20 2013 From: ckokkeng at dso.org.sg (Chew Kok Keng) Date: Sat May 4 13:43:22 2013 Subject: [odb-users] ODB for Windows 64 bits Application Message-ID: <20E19B3413064F4FA4771E0C05CAC4D4B643E8@Gawain.dsonet.corp.root> Hi, I would like to find out whether ODB supports windows 64bits application development. Regards, Chew From reza.jahanbakhshi at gmail.com Sun May 5 21:41:42 2013 From: reza.jahanbakhshi at gmail.com (Reza Jahanbakhshi) Date: Sun May 5 21:41:50 2013 Subject: [odb-users] table_name in ODB 2.2.0 Message-ID: Hi, In ODB 2.1.0 I could use object_traits::table_name to find physical name of table in database to use in custom queries. But ODB 2.2.0 there is no table_name member in object_trait class. What is the preferred method to achieve this? Thanks From boris at codesynthesis.com Mon May 6 02:47:24 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 6 02:47:34 2013 Subject: [odb-users] table_name in ODB 2.2.0 In-Reply-To: References: Message-ID: Hi Reza, Reza Jahanbakhshi writes: > In ODB 2.1.0 I could use object_traits::table_name to find physical > name of table in database to use in custom queries. But ODB 2.2.0 there is > no table_name member in object_trait class. What is the preferred method > to achieve this? In ODB 2.2.0 we've added multi-database support which required some changes to the traits structure. The table name is still there, but it is now in the database-specific object_traits_impl class rather than common object_traits (it is possible to map the same class to different tables in different databases). If you don't use multi-database support, then you can access the table name like this: odb::object_traits_impl::table_name If you do use multi-database support, then you will need to specify the database, for example: odb::object_traits_impl::table_name Boris From boris at codesynthesis.com Mon May 6 02:53:14 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 6 02:53:27 2013 Subject: [odb-users] ODB for Windows 64 bits Application In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B643E8@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B643E8@Gawain.dsonet.corp.root> Message-ID: Hi Chew, Chew Kok Keng writes: > I would like to find out whether ODB supports windows 64bits > application development. Yes, and we run 64-bit Windows tests for every release of ODB. To get started, get the pre-built Windows binary of the ODB compiler (odb-X.Y.Z-i686-windows) -- it works for both 32 and 64-bit development. Then, if you are using Visual Studio, when building the ODB runtimes, select the x64 platform as build target. The resulting libraries will be in the bin64/lib64 sub-directories. See the INSTALL files that some with each runtime for more information. If you are using MinGW-W64, then you may need to enable the 64- bit mode, depending on how your toolchain was built. Normally, passing -m64 is sufficient: ./configure CXXFLAGS=-m64 LDFLAFS=-m64 Boris From reza.jahanbakhshi at gmail.com Mon May 6 09:18:52 2013 From: reza.jahanbakhshi at gmail.com (Reza Jahanbakhshi) Date: Mon May 6 09:19:00 2013 Subject: [odb-users] table_name in ODB 2.2.0 In-Reply-To: References: Message-ID: Dear Boris, First thanks for you answer. Due to limits in ODB query language we use a lot of custom queries in our project. Wouldn't it be nice to have a cleaner syntax to access object table name in ODB queries? Currently I'm thinking about writing a wrapper template function like odb_table_name () and use is in our project. What do you suggest? Are you considering to put such facility in ODB in future? Again thank to you all for this great ORM system. On Mon, May 6, 2013 at 11:17 AM, Boris Kolpackov wrote: > Hi Reza, > > Reza Jahanbakhshi writes: > > > In ODB 2.1.0 I could use object_traits::table_name to find > physical > > name of table in database to use in custom queries. But ODB 2.2.0 there > is > > no table_name member in object_trait class. What is the preferred method > > to achieve this? > > In ODB 2.2.0 we've added multi-database support which required some > changes to the traits structure. The table name is still there, but > it is now in the database-specific object_traits_impl class rather > than common object_traits (it is possible to map the same class to > different tables in different databases). > > If you don't use multi-database support, then you can access the > table name like this: > > odb::object_traits_impl::table_name > > If you do use multi-database support, then you will need to specify > the database, for example: > > odb::object_traits_impl::table_name > > Boris > From boris at codesynthesis.com Tue May 7 11:57:35 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 7 11:56:29 2013 Subject: [odb-users] table_name in ODB 2.2.0 In-Reply-To: References: Message-ID: Hi Reza, Reza Jahanbakhshi writes: > First thanks for you answer. Due to limits in ODB query language we use a > lot of custom queries in our project. Wouldn't it be nice to have a cleaner > syntax to access object table name in ODB queries? Currently I'm thinking > about writing a wrapper template function like odb_table_name () > and use is in our project. What do you suggest? Are you considering to put > such facility in ODB in future? Isn't it already pretty much what we have in ODB? That is, in the general case, you need to provide two things in order to get the table name: the object type and the database. I suppose we could use a default value for the database to make life easier for people who are only using a single database. So you would just write: odb::object_traits_impl::table_name Also, probably a better solution to this problem would be to provide ODB support for the the kind of queries that you need. Can you show us some examples? Boris From matrixx at underald.net Wed May 8 04:51:07 2013 From: matrixx at underald.net (M@trixX) Date: Wed May 8 04:51:12 2013 Subject: [odb-users] incomplete types for query/result Message-ID: <201305080851.07683.matrixx@underald.net> Hello, I'm trying to access DB with ODB by following the manual example (http://www.codesynthesis.com/products/odb/doc/manual.xhtml#2.5), but I've been unsuccesfull for days... The load() function works, as expected, but when I try query, I allways got a lot of error messages from compiler about incomplete types result and query. I don't know, what I'm doing wrong. Am I missing something? my code (from file dbs1widget.cpp: --- #include "dbs1widget.h" #include #include #include #include #include #include "vozidlo.h" #include "vozidlo-odb.hxx" ... ... void dbs1Widget::zobrazVozidla() { typedef odb::query query; typedef odb::result result; using namespace std; using namespace odb::core; try { transaction t (db->begin ()); result r (db->query (query::typ > 30)); for (result::iterator i (r.begin ()); i != r.end (); ++i) { cout << "Hello, " << voz->TypVozidla() << "!" << endl; } t.commit (); } catch (const odb::exception& e) { cerr << e.what () << endl; //return 1; } } --- and errors from compiler: --- /usr/libexec/odb/i686-linux-gnu/include/odb/query.hxx:104:10: instantiated from 'odb::query_selector' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:49:28: instantiated from here /usr/libexec/odb/i686-linux-gnu/include/odb/query.hxx:89:65: error: no type named 'query_base_type' in 'struct odb::object_traits_impl' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:49:28: error: template argument 2 is invalid /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:49:35: error: invalid type in declaration before ';' token /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:56:17: instantiated from here /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:75:9: error: invalid use of incomplete type 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:53:9: error: declaration of 'struct odb::result_base' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:56:17: instantiated from here /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:82:39: error: invalid use of incomplete type 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:53:9: error: declaration of 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:93:45: error: invalid use of incomplete type 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:53:9: error: declaration of 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:101:5: error: invalid use of incomplete type 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:53:9: error: declaration of 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:215:43: error: invalid use of incomplete type 'struct odb::result_base' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:53:9: error: declaration of 'struct odb::result_base' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:56:37: error: 'query' is not a class or namespace /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:58:32: error: variable 'odb::result::iterator i' has initializer but incomplete type /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:58:41: error: invalid use of incomplete type 'odb::result::iterator {aka struct odb::result_iterator}' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:56:9: error: declaration of 'odb::result::iterator {aka struct odb::result_iterator}' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:58:57: error: invalid use of incomplete type 'odb::result::iterator {aka struct odb::result_iterator}' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:56:9: error: declaration of 'odb::result::iterator {aka struct odb::result_iterator}' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:58:41: instantiated from here /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:167:5: error: return type 'odb::result::iterator {aka struct odb::result_iterator}' is incomplete /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:169:7: error: using invalid field 'odb::result::impl_' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:170:9: error: using invalid field 'odb::result::impl_' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:172:36: error: using invalid field 'odb::result::impl_' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:172:36: error: invalid use of incomplete type 'odb::result::iterator {aka struct odb::result_iterator}' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:56:9: error: declaration of 'odb::result::iterator {aka struct odb::result_iterator}' /home/matrixx/skoal/dbs1/src/dbs1widget.cpp:58:57: instantiated from here /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:176:5: error: return type 'odb::result::iterator {aka struct odb::result_iterator}' is incomplete /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:178:24: error: invalid use of incomplete type 'odb::result::iterator {aka struct odb::result_iterator}' /usr/libexec/odb/i686-linux-gnu/include/odb/result.hxx:56:9: error: declaration of 'odb::result::iterator {aka struct odb::result_iterator}' --- What are those "(odb::database_id)5u", "(odb::class_kind)0u" ? Am I forgetting to include something? Or what Am I doing wrong? I'll appreciate any hints for this. From boris at codesynthesis.com Wed May 8 06:46:28 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 8 06:45:18 2013 Subject: [odb-users] incomplete types for query/result In-Reply-To: <201305080851.07683.matrixx@underald.net> References: <201305080851.07683.matrixx@underald.net> Message-ID: Hi, M@trixX writes: > /usr/libexec/odb/i686-linux-gnu/include/odb/query.hxx:89:65: error: no type > named 'query_base_type' in 'struct odb::object_traits_impl (odb::database_id)5u>' I am pretty sure you forgot to enable query support when compiling your headers with the ODB compiler. Try adding --generate-query (or -q for short). Boris From bioshocker at mail.ru Fri May 10 05:18:58 2013 From: bioshocker at mail.ru (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCa0L7QttC10LLQvdC40LrQvtCy?=) Date: Fri May 10 05:19:10 2013 Subject: [odb-users] odb compilation Visual Studio 2008 error Message-ID: <1368177538.261741235@f222.mail.ru> Hello everybody, I've got a problem related with pre-build ODB compilation files. At compile time i've got net error: "error C2660: 'odb::sqlite::default_value_traits::set_value' : function does not take 4 arguments". I've read this thread? http://70.85.31.65/pipermail/odb-users/2012-July/000657.html , and set next compilation parameters: "odb -d sqlite --profile boost -I C:\SDK\boost_1_53_0 C:\SDK\libodb-sqlite-2.2.1 --options-file C:\SDK\libodb-boost-2.2.0\odb\boost\uuid\uuid-sqlite.options --hxx-prologue '#include ' --output-dir $(ProjectDir)db --generate-schema --generate-query $(ProjectDir)db\coordinate.h $(ProjectDir)db\timestamp.h $(ProjectDir)db\odbtrackerstamp.h" but I've don't ?got successful result( please help me. .? From skh1002 at gmail.com Thu May 9 22:10:08 2013 From: skh1002 at gmail.com (skh) Date: Fri May 10 09:10:15 2013 Subject: [odb-users] Building odb-tests-2.2.0 on Mac with gcc-4.8.0: make errors In-Reply-To: Message-ID: Dear list, I have been recently trying to install ODB on a Mac computer running OS X 10.8 and I managed to do that with the exception of libodb-qt package (I will report it in a separate post). I am using gcc-4.8.0 and so far only libodb-sqlite runtime. I have gcc installed in /usr/gcc-4.8.0 (--program-suffix=-4.8) and all ODB-related components in /usr/odb. I was also able to build and run all of the examples in odb-examples-2.2.0. Today, I tried compiling odb-tests with the following invocation in the source folder: $ export PATH=/usr/gcc-4.8.0/bin:$PATH $ ./configure ODB=/usr/odb/bin/odb CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CPPFLAGS=-I/usr/odb/include LDFLAGS=-L/usr/odb/lib --with-database=sqlite $ make Unfortunately make fails with different errors depending on the CXXFLAGS passed to configure. If I specify CXXFLAGS=-std=c++0x, then make bombs out with this message: Making all in access ? Undefined symbols for architecture x86_64: "odb::vector_base::vector_base(odb::vector_base&&)?, referenced from: odb::vector >::vector(odb::vector >&&) in driver.o ? followed by a few other referencing entities in the same driver.o file. When I don?t specify CXXFLAGS, the error message is different: Making all in access make all-am ? test-odb.cxx:2463:13: error: ?move? is not a member of ?std? o.p2 (std::move (v)); I also tried using a separate build folder alongside the source one: $ export PATH=/usr/gcc-4.8.0/bin:$PATH $ cd ../odb-tests-build $ ../odb-tests-2.2.0/configure ODB=/usr/odb/bin/odb CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CPPFLAGS=-I/usr/odb/include LDFLAGS=-L/usr/odb/lib --with-database=sqlite $ make In this case, CXXFLAGS=-std=c++0x option produces the same error message as before, but if I omit it, the following is generated: make all-am ? In file included from ../../../odb-tests-2.2.0/common/definition/driver.cxx:19:0: ./test-odb.hxx:109:7: error: ?image_type? in ?class odb::access::composite_value_traits? does not name a type composite_value_traits< ::timeval, id_sqlite >::image_type time_value; ^ In case of c++11, it looks as if a library might be missing, which exports change-tracking container symbols, but so far I did not see any indication in the docs that this is a separate library. I would appreciate it if you could provide any hints on how to resolve this issue. Thank you in advance, S. From boris at codesynthesis.com Fri May 10 11:16:04 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 10 11:14:50 2013 Subject: [odb-users] Building odb-tests-2.2.0 on Mac with gcc-4.8.0: make errors In-Reply-To: References: Message-ID: Hi, skh writes: > If I specify CXXFLAGS=-std=c++0x, then make bombs out with this message: > > Undefined symbols for architecture x86_64: > "odb::vector_base::vector_base(odb::vector_base&&)?, > referenced from: odb::vector > >::vector(odb::vector >&&) > in driver.o This is actually a bug in libodb. A workaround would be to build libodb in the C++11 mode as well. > I don't specify CXXFLAGS, the error message is different: > Making all in access > make all-am > > test-odb.cxx:2463:13: error: `move' is not a member of `std' o.p2 (std::move > (v)); I am pretty sure you didn't run make clean before re-building in the C++98 mode and test-odb.cxx is the old file generated for C++11. > In this case, CXXFLAGS=-std=c++0x option produces the same error message as > before, but if I omit it, the following is generated: > > make all-am > In file included from > ../../../odb-tests-2.2.0/common/definition/driver.cxx:19:0: > ./test-odb.hxx:109:7: > error: 'image_type' in 'class odb::access::composite_value_traits (odb::database_id)1u>' > does not name a type > composite_value_traits< ::timeval, id_sqlite >::image_type time_value; I am not sure about this one though it can also be an artifact of dirty rebuild. Can you try these steps using clean source/build directories? Boris From boris at codesynthesis.com Fri May 10 13:07:13 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 10 13:05:59 2013 Subject: [odb-users] odb compilation Visual Studio 2008 error In-Reply-To: <1368177538.261741235@f222.mail.ru> References: <1368177538.261741235@f222.mail.ru> Message-ID: Hi, ????????? ?????????? writes: > Hello everybody, I've got a problem related with pre-build ODB > compilation files. At compile time i've got net error: "error > C2660: 'odb::sqlite::default_value_traits::set_value' : > function does not take 4 arguments". > > I've read this thread [...], and set next compilation parameters: > --options-file C:\SDK\libodb-boost-2.2.0\odb\boost\uuid\uuid-sqlite.options > --hxx-prologue '#include ' I don'see what in that thread made you think that you need to add these options. You definitely don't need them. Your problem is that you are using an unsupported mapping between a C++ type and a database type (e.g., mapping int to TEXT). Can you you show the fragment of code that this error points to as well as the corresponding persistent class? Boris From bioshocker at mail.ru Sat May 11 05:26:24 2013 From: bioshocker at mail.ru (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCa0L7QttC10LLQvdC40LrQvtCy?=) Date: Sat May 11 05:26:32 2013 Subject: =?UTF-8?B?RndkOiBSZVsyXTogW29kYi11c2Vyc10gb2RiIGNvbXBpbGF0aW9uIFZpc3Vh?= =?UTF-8?B?bCBTdHVkaW8gMjAwOCBlcnJvcg==?= Message-ID: <1368264383.222680403@f358.mail.ru> >I don'see what in that thread made you think that you need to add these >options. You definitely don't need them. > >Your problem is that you are using an unsupported mapping between a C++ >type and a database type (e.g., mapping int to TEXT). Can you you show >the fragment of code that this error points to as well as the >corresponding persistent class? > >Boris I've got some supposses, what i had wrong mapped type in database, but don't think what this error showed up in compile-time. I think, problems here: ? #pragma db value class TimeStamp { public: TimeStamp( tm time); const tm getCurrentTime(); private: friend class odb::access; #pragma db type("DATETIME") tm time_; }; } and/or here? ? #pragma db object class ODBTrackerStamp { public: ODBTrackerStamp( DeviceId deviceId, Coordinate coordinate, TimeStamp timeStamp); const Coordinate& getCoordinate() const; const db::TimeStamp& getTimeStamp() const; private: friend class odb::access; #pragma db id #pragma db type("NVARCHAR(36)") boost::uuids::uuid?deviceId_; Coordinate coordinate_; TimeStamp timeStamp_; };? From skh1002 at gmail.com Fri May 10 23:46:35 2013 From: skh1002 at gmail.com (skh) Date: Sat May 11 06:39:09 2013 Subject: [odb-users] Building odb-tests-2.2.0 on Mac with gcc-4.8.0: make errors In-Reply-To: Message-ID: Hallo Boris, Today, I just removed everything related to odb from /usr, deleted all the source/build folders and started from scratch: 1. Try installing libcutl-1.7.1 with C++11 option (no external Boost) $ cd /Developer/libcutl-1.7.1 && mkdir build && cd build $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x --prefix=/usr/odb $ make Make errors out: ../../cutl/details/boost/smart_ptr/shared_ptr.hpp:305:9: error: use of deleted function 'cutl_details_boost::shared_ptr:: shared_ptr(const cutl_details_boost:: shared_ptr&)? this_type(r).swap(*this); ^ Building without C++11 option: $ make clean $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 --prefix=/usr/odb $ make && sudo make install 2. Install libodb-2.2.2 with C++11 option $ cd /Developer/libodb-2.2.2 && mkdir build && cd build $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x --prefix=/usr/odb--prefix=/usr/odb $ make && sudo make install 3. Install libodb-sqlite-2.2.1 with C++11 option $ cd /Developer/libodb-sqlite-2.2.1 && mkdir build && cd build $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x CPPFLAGS=-I/usr/odb/include LDFLAGS=-L/usr/odb/lib --prefix=/usr/odb $ make && sudo make install 4. Install libodb-qt-2.2.0 with C++11 option. By the way, I recommend including into the INSTALL file a line about linking against QtCore on Mac: it took me a while to figure out that Qt is built with frameworks and not libraries by default. I also could not use the option --with-libodb=../../libodb-2.2.2/build because libodb was only found if it was specified in CPPFLAGS and LDFLAGS. $ cd /Developer/libodb-qt-2.2.0 && mkdir build && cd build $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x CPPFLAGS='-I/usr/odb/include -I/Developer/Qt5.0.2/5.0.2/clang_64/include? LDFLAGS='-L/usr/odb/lib -F/Developer/Qt5.0.2/5.0.2/clang_64/lib? --prefix=/usr/odb --with-libodb=../../libodb-2.2.2/build $ make && sudo make install 5. Install libodb-boost-2.2.0 with C++11 option. $ cd /Developer/libodb-boost-2.2.0 && mkdir build && cd build $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x CPPFLAGS='-I/usr/odb/include -I/Developer/boost_1_53_0? LDFLAGS='-L/usr/odb/lib -L/Developer/boost_1_53_0/stage/lib' --prefix=/usr/odb $ make && sudo make install 6. Try installing odb-2.2.1 compiler with C++11 option. $ cd /Developer/odb-2.2.1 && mkdir build && cd build $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x CPPFLAGS=-I/usr/odb/include LDFLAGS=-L/usr/odb/lib --prefix=/usr/odb $ make Make borks out with a C++ compiler error: ../../odb/parser.cxx:1821:7: error: reference to 'array' is ambiguous array& a (unit_->new_node (file, line, clmn, t, size)); ^ In file included from? ../../odb/semantics/derived.hxx:384:9: note: candidates are: class semantics::array class array: public derived_type ^ In file included from? /usr/gcc-4.8.0/include/c++/4.8.0/array:81:12: note: template struct std::array struct array ^ ... ../../odb/semantics/unit.hxx:109:5: note: template argument deduction/substitution failed: ../../odb/parser.cxx:1821:66: error: template argument 1 is invalid array& a (unit_->new_node (file, line, clmn, t, size)); ^ ../../odb/parser.cxx:1821:67: error: 'a' was not declared in this scope array& a (unit_->new_node (file, line, clmn, t, size)); ^ Compiling odb without C++11 option. $ make clean $ ../configure CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CPPFLAGS=-I/usr/odb/include LDFLAGS=-L/usr/odb/lib --prefix=/usr/odb $ make && sudo make install 7. Build odb-examples-2.2.0 with C++11 option, libodb-qt, and libodb-boost. $ cd /Developer/odb-examples-2.2.0 && mkdir build && cd build $ ../configure ODB=/usr/odb/bin/odb CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x CPPFLAGS='-I/usr/odb/include -I/Developer/boost_1_53_0 -I/Developer/Qt5.0.2/5.0.2/clang_64/include? LDFLAGS='-L/usr/odb/lib -L/Developer/boost_1_53_0 -F/Developer/Qt5.0.2/5.0.2/clang_64/lib' --prefix=/usr/odb --with-database=sqlite $ make && sudo make install For some reason, runnig examples or ?make check? fails with an error like this: dyld: Library not loaded: libboost_system.dylib Referenced from: /Developer/odb-examples-2.2.0/build/./inheritance/polymorphism/driver Reason: image not found Trace/BPT trap: 5 Maybe, the problem is in my Boost configuration, but I noticed that configure fails to detect date-time and system libraries from Boost, even though it does detect Boost itself. In the log it seems that configure looks for names like ?boost_date_time?, whereas in the Boost lib folder the names are ?libboost_date_time?. I fixed this with the following band-aid: $ export DYLD_FALLBACK_LIBRARY_PATH=/Developer/boost_1_53_0/stage/lib After this, I can run all the examples without problems. 8. Build odb-tests-2.2.0 with C++11 option. $ cd /Developer/odb-examples-2.2.0 && mkdir build && cd build $ ../configure ODB=/usr/odb/bin/odb CC=gcc-4.8 CXX=g++-4.8 CPP=cpp-4.8 CXXFLAGS=-std=c++0x CPPFLAGS='-I/usr/odb/include -I/Developer/boost_1_53_0 -I/Developer/Qt5.0.2/5.0.2/clang_64/include? LDFLAGS='-L/usr/odb/lib -L/Developer/boost_1_53_0 -F/Developer/Qt5.0.2/5.0.2/clang_64/lib? --prefix=/usr/odb --with-database=sqlite $ make Unfortunately, make terminates with one of the errors I already mentioned in the previous message: g++-4.8 -DHAVE_CONFIG_H -I'../../libcommon' -I'../../../libcommon' -I'.? -I'../../../common/definition' -I/usr/odb/include -I/Developer/boost_1_53_0 -I/Developer/Qt5.0.2/5.0.2/clang_64/include -std=c++0x -D_THREAD_SAFE -MT driver.o -MD -MP -MF $depbase.Tpo -c -o driver.o ../../../common/definition/driver.cxx &&\ mv -f $depbase.Tpo $depbase.Po In file included from ../../../common/definition/driver.cxx:19:0: ./test-odb.hxx:109:7: error: ?image_type? in ?class odb::access::composite_value_traits? does not name a type composite_value_traits< ::timeval, id_sqlite >::image_type time_value; ^ I may try building libodb and tests both without C++11 option tomorrow, especially if you think it makes sense. Maybe, everything is Ok with ODB, but I would still like to run the tests just to double-check. Thank you for your time, S. On 10-05-13 8:16 a, "Boris Kolpackov" wrote: >Hi, > >skh writes: > >> If I specify CXXFLAGS=-std=c++0x, then make bombs out with this >>message: >> >> Undefined symbols for architecture x86_64: >> "odb::vector_base::vector_base(odb::vector_base&&)?, >> referenced from: odb::vector >> >::vector(odb::vector >&&) >> in driver.o > >This is actually a bug in libodb. A workaround would be to build libodb >in the C++11 mode as well. > > >> I don't specify CXXFLAGS, the error message is different: >> Making all in access >> make all-am >> >> test-odb.cxx:2463:13: error: `move' is not a member of `std' o.p2 >>(std::move >> (v)); > >I am pretty sure you didn't run make clean before re-building in the C++98 >mode and test-odb.cxx is the old file generated for C++11. > > >> In this case, CXXFLAGS=-std=c++0x option produces the same error >>message as >> before, but if I omit it, the following is generated: >> >> make all-am >> In file included from >> ../../../odb-tests-2.2.0/common/definition/driver.cxx:19:0: >> ./test-odb.hxx:109:7: >> error: 'image_type' in 'class >>odb::access::composite_value_traits> (odb::database_id)1u>' >> does not name a type >> composite_value_traits< ::timeval, id_sqlite >::image_type time_value; > >I am not sure about this one though it can also be an artifact of dirty >rebuild. Can you try these steps using clean source/build directories? > > >Boris From bioshocker at mail.ru Sat May 11 07:34:38 2013 From: bioshocker at mail.ru (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCa0L7QttC10LLQvdC40LrQvtCy?=) Date: Sat May 11 07:34:46 2013 Subject: =?UTF-8?B?W29kYi11c2Vyc10gb2RiIGNvbXBpbGF0aW9uIFZpc3VhbCBTdHVkaW8gMjAw?= =?UTF-8?B?OCBlcnJvcg==?= Message-ID: <1368272078.838850686@f220.mail.ru> >I don'see what in that thread made you think that you need to add these >options. You definitely don't need them. > >Your problem is that you are using an unsupported mapping between a C++ >type and a database type (e.g., mapping int to TEXT). Can you you show >the fragment of code that this error points to as well as the >corresponding persistent class? > >Boris I've got some supposses, what i had wrong mapped type in database, but don't think what this error showed up in compile-time. I think, problems here: ? #pragma db value class TimeStamp { public: TimeStamp( tm time); const tm getCurrentTime(); private: friend class odb::access; #pragma db type("DATETIME") tm time_; }; } and/or here? ? #pragma db object class ODBTrackerStamp { public: ODBTrackerStamp( DeviceId deviceId, Coordinate coordinate, TimeStamp timeStamp); const Coordinate& getCoordinate() const; const db::TimeStamp& getTimeStamp() const; private: friend class odb::access; #pragma db id #pragma db type("NVARCHAR(36)") boost::uuids::uuid?deviceId_; Coordinate coordinate_; TimeStamp timeStamp_; };? Alexander. ---------------------------------------------------------------------- From boris at codesynthesis.com Sat May 11 11:00:09 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat May 11 10:58:54 2013 Subject: Fwd: Re[2]: [odb-users] odb compilation Visual Studio 2008 error In-Reply-To: <1368264383.222680403@f358.mail.ru> References: <1368264383.222680403@f358.mail.ru> Message-ID: Hi, Please don't send multiple copies of the same question to the mailing list. It won't make us reply faster. If any, it will have the exact opposite effect. ????????? ?????????? writes: > #pragma db type("DATETIME") > tm time_; ODB doesn't provide a default mapping for struct tm. Generally, ODB cannot "auto-magically" map any C++ type to any database type. The only mappings that you can use are those that are documented in the manual or those that you provided yourself. Also note that SQLite doesn't have the DATETIME type. So, in this case your options are (in the order of increasing difficulty): 1. Instead of struct tm, use a date-time type that is supported by ODB. For example, boost::posix_time::ptime from the Boost date- time library. 2. Provide your own implementation of struct tm to an SQLite type mapping. See this guide for details: http://www.codesynthesis.com/~boris/blog/2012/10/16/custom-cxx-to-database-type-mapping-in-odb/ > #pragma db type("NVARCHAR(36)") > boost::uuids::uuid deviceId_; The same problem here. ODB only supports mapping of Boost uuid to SQLite BLOB. Also, SQLite doesn't have the NVARCHAR type. So your options here are: 1. Use the default mapping for uuid. 2. Use a string instead of uuid if you want a text representation. 3. Provide your own mapping of uuid to TEXT. Boris From boris at codesynthesis.com Sat May 11 16:40:53 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat May 11 16:39:40 2013 Subject: [odb-users] Building odb-tests-2.2.0 on Mac with gcc-4.8.0: make errors In-Reply-To: References: Message-ID: Hi, skh writes: > ./test-odb.hxx:109:7: error: ?image_type? in ?class > odb::access::composite_value_traits? > does not name a type > composite_value_traits< ::timeval, id_sqlite >::image_type time_value; That's very strange. This test works just fine for me. The composite_value_traits specialization should be defined by the generated time-mapping-odb.hxx file. Can you check that this file is in fact generated and that it defines this specialization which in turn defines the image_type struct? Boris From bioshocker at mail.ru Sat May 11 12:46:54 2013 From: bioshocker at mail.ru (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCa0L7QttC10LLQvdC40LrQvtCy?=) Date: Sat May 11 16:39:50 2013 Subject: =?UTF-8?B?UmVbNF06IEZ3ZDogW29kYi11c2Vyc10gb2RiIGNvbXBpbGF0aW9uIFZpc3Vh?= =?UTF-8?B?bCBTdHVkaW8gMjAwOCBlcnJvcg==?= In-Reply-To: References: <1368264383.222680403@f358.mail.ru> Message-ID: <1368290814.782575382@f232.mail.ru> >Hi, > >Please don't send multiple copies of the same question to the mailing >list. It won't make us reply faster. If any, it will have the exact >opposite effect. > > >????????? ?????????? < bioshocker@mail.ru > writes: > >> #pragma db type("DATETIME") >> tm time_; > >ODB doesn't provide a default mapping for struct tm. Generally, ODB >cannot "auto-magically" map any C++ type to any database type. The >only mappings that you can use are those that are documented in the >manual or those that you provided yourself. Also note that SQLite >doesn't have the DATETIME type. > >So, in this case your options are (in the order of increasing >difficulty): > >1. Instead of struct tm, use a date-time type that is supported by >???ODB. For example, boost::posix_time::ptime from the Boost date- >???time library. > >2. Provide your own implementation of struct tm to an SQLite type >???mapping. See this guide for details: > >??? http://www.codesynthesis.com/~boris/blog/2012/10/16/custom-cxx-to-database-type-mapping-in-odb/ > > >> #pragma db type("NVARCHAR(36)") >> boost::uuids::uuid deviceId_; > >The same problem here. ODB only supports mapping of Boost uuid to SQLite >BLOB. Also, SQLite doesn't have the NVARCHAR type. So your options here >are: > >1. Use the default mapping for uuid. > >2. Use a string instead of uuid if you want a text representation. > >3. Provide your own mapping of uuid to TEXT. > >Boris Thanks, it was helpful, but i get new error at Pre-Build event: C:\SDK\libodb-sqlite-2.2.1/odb/sqlite/details/config.hxx:12:4: error: #error libodb-sqlite header included in odb-compiled header? From boris at codesynthesis.com Sat May 11 16:44:41 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat May 11 16:43:28 2013 Subject: Fwd: [odb-users] odb compilation Visual Studio 2008 error In-Reply-To: <1368290814.782575382@f232.mail.ru> References: <1368264383.222680403@f358.mail.ru> <1368290814.782575382@f232.mail.ru> Message-ID: Hi, ????????? ?????????? writes: > Thanks, it was helpful, but i get new error at Pre-Build event: > C:\SDK\libodb-sqlite-2.2.1/odb/sqlite/details/config.hxx:12:4: error: > #error libodb-sqlite header included in odb-compiled header Well, the error says what the problem is: you have included a header from the database-specific runtime (libodb-sqlite) into a header file that is compiled with the ODB compiler. This is not supported. For example, if you include odb/sqlite/database.hxx into your header, then you will get an error like this. Boris From skh1002 at gmail.com Sun May 12 01:09:17 2013 From: skh1002 at gmail.com (skh) Date: Sun May 12 08:03:11 2013 Subject: [odb-users] Building odb-tests-2.2.0 on Mac with gcc-4.8.0: make errors In-Reply-To: Message-ID: Hi Boris, I have just checked and yes, there is file /build/common/definition/time-mapping-odb.hxx and it does define template <> class access::composite_value_traits< ::timeval, id_sqlite > The struct image_type is, indeed, defined inside. However, what I also found out is that the file /build/common/definition/test-odb.hxx, which is quoted in the error message references composite_value_traits< ::timeval, id_sqlite >, but does not #include ?time-mapping-odb.hxx?. I?ve just manually included this file into test-orb.hxx (in the mentioned build location) and guess what, make does not complain now. I don?t really know why ?time-mapping-odb.hxx? seems to get included in your builds and not in mine. I probably would not be able to hunt this down. I ran make check and all tests but one pass. The threads test fails with message ?database operation timeout? repeated many times and another one in between: ?timeout1: cannot start a transaction within a transaction?. When I compiled some of the packages, I vaguely remember that there was a warning message that sqlite3 library (the system one on Mac) was compiled without some concurrency option and that would limit multi-thread capabilities. I don?t know if this may be the reason of failed test. Do you have any idea of the possible reason? Today I don?t have time to investigate this any more. Maybe, I will tinker with it a little bit tomorrow. Take care, S. On 11-05-13 1:40 p, "Boris Kolpackov" wrote: >Hi, > >skh writes: > >> ./test-odb.hxx:109:7: error: ?image_type? in ?class >> odb::access::composite_value_traits? >> does not name a type >> composite_value_traits< ::timeval, id_sqlite >::image_type time_value; > >That's very strange. This test works just fine for me. > >The composite_value_traits specialization should be >defined by the generated time-mapping-odb.hxx file. Can you check that >this file is in fact generated and that it defines this specialization >which in turn defines the image_type struct? > >Boris From bioshocker at mail.ru Sun May 12 05:18:42 2013 From: bioshocker at mail.ru (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCa0L7QttC10LLQvdC40LrQvtCy?=) Date: Sun May 12 08:03:11 2013 Subject: =?UTF-8?B?UmVbNl06IEZ3ZDogW29kYi11c2Vyc10gb2RiIGNvbXBpbGF0aW9uIFZpc3Vh?= =?UTF-8?B?bCBTdHVkaW8gMjAwOCBlcnJvcg==?= In-Reply-To: References: <1368264383.222680403@f358.mail.ru> <1368290814.782575382@f232.mail.ru> Message-ID: <1368350321.712027934@f117.mail.ru> >For example, if you include odb/sqlite/database.hxx into your header, >then you will get an error like this. > >Boris Thank you so much, Boris, it was this error!? From boris at codesynthesis.com Sun May 12 17:15:49 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun May 12 17:14:29 2013 Subject: [odb-users] Building odb-tests-2.2.0 on Mac with gcc-4.8.0: make errors In-Reply-To: References: Message-ID: Hi, skh writes: > I don't really know why time-mapping-odb.hxx seems to get included in > your builds and not in mine. Yes, this is very strange. I just re-tested it on my Debian box with GCC 4.8 and the include is definitely there. So it works for me with GCC 4.8 on Debian and with GCC 4.7 on OS X. I don't have GCC 4.8 on OS X readily available, so can't test that right now. Could you therefore run this test for me: http://www.codesynthesis.com/~boris/tmp/odb/include-test.tar.gz After unpacking, compile all the headers with the ODB compiler (may need to add -I for libodb): odb -d sqlite *.hxx After that, can you check the beginning of the test-odb.hxx file? It should contain #include directives for v1-odb.hxx, v2-odb.hxx, and v3-odb.hxx. Also, if you could send me all the generated files (*-odb.?xx), then that would be great! > When I compiled some of the packages, I vaguely remember that there was a > warning message that sqlite3 library (the system one on Mac) was compiled > without some concurrency option and that would limit multi-thread > capabilities. I don't know if this may be the reason of failed test. Yes, that's the reason. If SQLite was built without unlock notify support, then it cannot be used from multiple threads simultaneously. Boris From rjg1094 at gmail.com Tue May 14 19:13:49 2013 From: rjg1094 at gmail.com (Rafal Grasman) Date: Tue May 14 20:13:33 2013 Subject: [odb-users] Error when trying to use odb compiler on custom class Message-ID: Dear ODB-Users, I have a problem when compiling my class through the ODB compiler, The problem is that I get this error: user.hxx:110:12: error: unable to map C++ type '::__gnu_cxx::new_allocator< ::std::tuple< ::std::basic_string< char, ::std::char_traits< char >, ::std::allocator< char > >, long long unsigned int, ::std::basic_string< char, ::std::char_traits< char >, ::std::allocator< char > >, long long unsigned int > >::value_type' used in data member 'bans_' to a MySQL database type user.hxx:110:12: info: use '#pragma db value_type' to specify the database type This recently happend when I tried to add my ban system, just like in the examples (with employees emails): // bans. // v> typedef std::vector> bans_type; const bans_type& bans () const { return bans_; } bans_type& bans () { return bans_; } private: bans_type bans_; This is the full header is needed: #ifdef EXE24_EXPORTS #pragma once #endif #include #include #include #include #define acmf(variable_name,variable_type) \ const variable_type& variable_name () const \ { \ return variable_name ## _; \ } \ void variable_name (variable_type variable_name) \ { \ variable_name ## _ = variable_name; \ } #define accessor(variable_name,variable_type) \ const variable_type& variable_name () const \ { \ return variable_name ## _; \ } #pragma db object class user { public: user () {} user ( std::string nickname, std::string password, unsigned long long register_date, unsigned int kills, unsigned int deaths, unsigned int joins, unsigned int disconnects, unsigned int kicks, unsigned long long experience, unsigned long long admin, unsigned long long banned ): nickname_(nickname), password_(password), register_date_(register_date), kills_(kills), deaths_(deaths), joins_(joins), disconnects_(disconnects), kicks_(kicks), experience_(experience), admin_(admin), banned_(banned) { } // Standard accessor/modifier names. Auto-discovered by ODB. // acmf(nickname,std::string); acmf(password,std::string); acmf(register_date,unsigned long long); acmf(kills,unsigned int); acmf(deaths,unsigned int); acmf(joins,unsigned int); acmf(disconnects,unsigned int); acmf(kicks,unsigned int); acmf(experience,unsigned long long); acmf(admin,unsigned long long); acmf(banned,unsigned long long); accessor(id,unsigned long); // bans. // v> typedef std::vector> bans_type; const bans_type& bans () const { return bans_; } bans_type& bans () { return bans_; } private: friend class odb::access; #pragma db id auto unsigned long id_; std::string nickname_; std::string password_; unsigned long long register_date_; unsigned int kills_; unsigned int deaths_; unsigned int joins_; unsigned int disconnects_; unsigned int kicks_; unsigned long long experience_; unsigned long long admin_; unsigned long long banned_; bans_type bans_; }; Could anyone point me out what I'm doing wrong? Thanks in advance! From boris at codesynthesis.com Tue May 14 20:27:02 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 14 20:25:43 2013 Subject: [odb-users] Error when trying to use odb compiler on custom class In-Reply-To: References: Message-ID: Hi Rafal, Rafal Grasman writes: > // bans. > // v> > typedef std::vector long,std::string,unsigned long long>> bans_type; The vector element is a composite (multi-column) value type. You need to declare such a type with the db value pragma so that the ODB compiler can generate the database support code for it. ODB allows you to "create" a composite value type out of a class template instantiations (e.g., std::tuple). Here is an example: typedef std::tuple ban_type; #pragma db value(ban_type) #pragma db object class object { ... typedef std::vector bans_type; bans_type bans; }; Boris From rjg1094 at gmail.com Tue May 14 21:09:49 2013 From: rjg1094 at gmail.com (Rafal Grasman) Date: Tue May 14 21:09:57 2013 Subject: Fwd: [odb-users] Error when trying to use odb compiler on custom class In-Reply-To: References: Message-ID: Sorr, fogot to CC, I'm new to mailing lists :$ Response: Wow, so simple! Thank you really much, saved my day :D Ah, it works for the ODB compiler but now Visual Studio is complaining on the generated header ( http://ideone.com/dcWoJw ) :( 1>------ Build started: Project: Exe24++, Configuration: Release Win32 ------ 1> pch.cpp 1> Compiling precompiled header... 1>C:\Users\Rafal\Documents\Visual Studio 2012\Projects\Exe24++\classes/user-odb.hxx(415): error C2027: use of undefined type 'odb::access::composite_value_traits' 1> with 1> [ 1> T=odb::access::object_traits_impl::bans_traits::value_type, 1> DB=id_mysql 1> ] 1> ...done ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== From boris at codesynthesis.com Tue May 14 22:58:27 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 14 22:57:09 2013 Subject: Fwd: [odb-users] Error when trying to use odb compiler on custom class In-Reply-To: References: Message-ID: Hi Rafal, Rafal Grasman writes: > Ah, it works for the ODB compiler but now Visual Studio is complaining on > the generated header I tried your example, and, actually, mapping std::tuple is tricky because it doesn't contain the members directly (like, for example, std::pair). Rather, it uses base classes to "allocate" the required number of elements. So, if you don't have a requirement to use tuples, then it will probably be much easier and more straightforward to reimplement this as a struct/class. For example: #pragma db value struct ban_type { std::string first; unsigned long long second; std::string third; unsigned long long fourth; }; You will probably want to use more descriptive names instead of first, second, etc. Now, if you must use std::tuple, then it should be possible to map it using the virtual data member feature in ODB. For example: typedef std::tuple ban_type; #pragma db value(ban_type) transient #pragma db member(ban_type::first) virtual(std::string) access(std::get<0> (this)) #pragma db member(ban_type::second) virtual(unsigned long long) access(std::get<1> (this)) #pragma db member(ban_type::third) virtual(std::string) access(std::get<2> (this)) #pragma db member(ban_type::fourth) virtual(unsigned long long) access(std::get<3> (this)) As you can see it is quite verbose. Above I said "should" instead of "can" because the current version of ODB (2.2.0) has a bug that prevents this mapping from working. I've fixed it for the next release of ODB so once 2.3.0 is out, it will work. Boris From tenchu.tarik at hotmail.fr Wed May 15 10:39:40 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Wed May 15 10:39:47 2013 Subject: [odb-users] Boost Error While Compiling Message-ID: Hello I want to use the Boost date_time element in my program but I have a problem during the compilation. I compiled the boost library and the libodb-boost. My compilation command line is : ..\ODB\odb-2.2.1-i686-windows\bin\odb -I ..\boost_1_53_0\stage\lib -I ..\ODB\libodb-boost-2.2.0\lib --profile boost/date-time/posix-time -d mssql --std c++11 --generate-query --generate-schema Account.hxx I've got this error message : odb\odb-2.2.1-i686-windows\mingw\bin\../../mingw/include/odb/boost/date-time/mssql/posix-time-mapping.hxx:8:59: fatal error: boost/date_time/posix_time/posix_time_types.hpp: No such file or directory Can someone help me to handle this please? Kind Regards, Tarik From boris at codesynthesis.com Wed May 15 15:21:39 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 15 15:20:19 2013 Subject: [odb-users] Boost Error While Compiling In-Reply-To: References: Message-ID: Hi Tarik, Tarik BENZ writes: > ..\ODB\odb-2.2.1-i686-windows\bin\odb -I ..\boost_1_53_0\stage\lib ... The -I option expects the path to headers while you are passing the location of Boost libraries. Try something like this: -I ..\boost_1_53_0 Boris From rjg1094 at gmail.com Thu May 16 09:35:33 2013 From: rjg1094 at gmail.com (Rafal Grasman) Date: Thu May 16 09:35:41 2013 Subject: Fwd: [odb-users] Error when trying to use odb compiler on custom class In-Reply-To: References: Message-ID: Yep this totally works (struct), I just commented out the tuple as for now, thank you very much! Amazing software :) I really hate making SQL queries ;f 2013/5/15 Boris Kolpackov > Hi Rafal, > > Rafal Grasman writes: > > > Ah, it works for the ODB compiler but now Visual Studio is complaining on > > the generated header > > I tried your example, and, actually, mapping std::tuple is tricky > because it doesn't contain the members directly (like, for example, > std::pair). Rather, it uses base classes to "allocate" the required > number of elements. > > So, if you don't have a requirement to use tuples, then it will > probably be much easier and more straightforward to reimplement > this as a struct/class. For example: > > #pragma db value > struct ban_type > { > std::string first; > unsigned long long second; > std::string third; > unsigned long long fourth; > }; > > You will probably want to use more descriptive names instead of first, > second, etc. > > Now, if you must use std::tuple, then it should be possible to map it > using the virtual data member feature in ODB. For example: > > typedef std::tuple unsigned long long, > std::string, > unsigned long long> ban_type; > > #pragma db value(ban_type) transient > #pragma db member(ban_type::first) virtual(std::string) access(std::get<0> > (this)) > #pragma db member(ban_type::second) virtual(unsigned long long) > access(std::get<1> (this)) > #pragma db member(ban_type::third) virtual(std::string) access(std::get<2> > (this)) > #pragma db member(ban_type::fourth) virtual(unsigned long long) > access(std::get<3> (this)) > > As you can see it is quite verbose. > > Above I said "should" instead of "can" because the current version of > ODB (2.2.0) has a bug that prevents this mapping from working. I've > fixed it for the next release of ODB so once 2.3.0 is out, it will > work. > > Boris > From tenchu.tarik at hotmail.fr Thu May 16 12:27:59 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Thu May 16 12:28:06 2013 Subject: [odb-users] Error Using Boost::date_time Message-ID: Hello, I am trying to use the boost::date_time with odb, but i encountered some error. This is an example of error : Error 1458 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall odb::boost::date_time::special_value::special_value(void)" (__imp_??0special_value@date_time@boost@odb@@QAE@XZ) Can Someone help me please? Tarik From boris at codesynthesis.com Thu May 16 19:03:21 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 16 19:02:02 2013 Subject: [odb-users] Error Using Boost::date_time In-Reply-To: References: Message-ID: Hi Tarik, Tarik BENZ writes: > I am trying to use the boost::date_time with odb, but i encountered > some error. > > Error 1458 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall odb::boost::date_time::special_value::special_value(void)" (__imp_??0special_value@date_time@boost@odb@@QAE@XZ) You need to link to the libodb-boost library. Boris From maik.lathan at hicknhack-software.com Fri May 17 06:46:12 2013 From: maik.lathan at hicknhack-software.com (Maik Lathan) Date: Fri May 17 08:58:47 2013 Subject: [odb-users] forced_rollback c'tor, d'tor and copy c'tor are unresolved symbols Message-ID: <571e66ab0825e9a149a475674ef93afd@hicknhack-software.com> I try to compile libodb-sqlite-vc10 with Visual Studio 2010. I followed all described steps and compiled QSLite3 with provided Visual Studio 2010 Solution. Everything compiled fine. When I try to build libodb-sqlite-vc10 I get this compiler warning: x:\experiments\odb\libodb-sqlite-2.2.1\odb\sqlite\exceptions.cxx(21): warning C4273: 'odb::sqlite::forced_rollback::what' : inconsistent dll linkage x:\experiments\odb\libodb-sqlite-2.2.1\odb\sqlite\exceptions.hxx(31) : see previous definition of 'what' and this linker errors: error.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall odb::sqlite::forced_rollback::~forced_rollback(void)" (??1forced_rollback@sqlite@odb@@UAE@XZ) error.obj : error LNK2001: unresolved external symbol "public: __thiscall odb::sqlite::forced_rollback::forced_rollback(struct odb::sqlite::forced_rollback const &)" (??0forced_rollback@sqlite@odb@@QAE@ABU012@@Z) X:\experiments\odb\libodb-sqlite-2.2.1\odb\sqlite\..\..\bin\odb-sqlite-d-2.2-vc10.dll : fatal error LNK1120: 3 unresolved externals Normally the compiler would generate all the missing constructors/destructor. I wonder if this problem is related to this bugfix release: http://www.codesynthesis.com/pipermail/odb-announcements/2013/000032.html -- Maik Lathan Gesch?ftsf?hrer Mobil: +49 (157) 747 090 11 HicknHack Software GmbH Bayreuther Str. 32 D-01187 Dresden Fon: +49 (351) 32 978 382 Web: http://hicknhack-software.com Email: contact@hicknhack-software.com Gesch?ftsf?hrer: Andreas Reischuck, Maik Lathan, Michael Starke Sitz: Dresden Handelsregister: Amtsgericht Dresden, HRB 30351 From boris at codesynthesis.com Fri May 17 12:52:04 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 17 12:50:53 2013 Subject: [odb-users] libodb-sqlite 2.2.2 bugfix released Message-ID: Hi, New bugfix release for the SQLite ODB runtime library (libodb-sqlite) is now available. It fixes an incorrect export macro in the forced_rollback exception. This bug only affects Windows builds. You can download the new packages from the ODB download page: http://www.codesynthesis.com/products/odb/download.xhtml SHA1 checksums for the files in this release are as follows: bf47360c65cf79ff9104b26c8e93978950d4eb8b libodb-sqlite-2.2.2.tar.bz2 7fc195c9f7848c709a3179ecebfb08dffdd1c16d libodb-sqlite-2.2.2.tar.gz 1f627d4d5f8e3f10466396c60f004c11bc664708 libodb-sqlite-2.2.2.zip Boris From boris at codesynthesis.com Fri May 17 12:57:32 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 17 12:56:16 2013 Subject: [odb-users] forced_rollback c'tor, d'tor and copy c'tor are unresolved symbols In-Reply-To: <571e66ab0825e9a149a475674ef93afd@hicknhack-software.com> References: <571e66ab0825e9a149a475674ef93afd@hicknhack-software.com> Message-ID: Hi Maik, Maik Lathan writes: > When I try to build libodb-sqlite-vc10 I get this compiler warning: > x:\experiments\odb\libodb-sqlite-2.2.1\odb\sqlite\exceptions.cxx(21): > warning C4273: 'odb::sqlite::forced_rollback::what' : inconsistent dll > linkage > x:\experiments\odb\libodb-sqlite-2.2.1\odb\sqlite\exceptions.hxx(31) : > see previous definition of 'what' This has just been fixed with the release of libodb-sqlite-2.2.2: http://codesynthesis.com/pipermail/odb-announcements/2013/000034.html Thanks for reporting this! Boris From ckokkeng at dso.org.sg Sat May 18 02:06:23 2013 From: ckokkeng at dso.org.sg (Chew Kok Keng) Date: Sat May 18 10:39:02 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> Message-ID: <20E19B3413064F4FA4771E0C05CAC4D4B6E55F@Gawain.dsonet.corp.root> Pardon me for the missing subject ________________________________ From: Chew Kok Keng Sent: Saturday, May 18, 2013 2:01 PM To: odb-users@codesynthesis.com Subject: Hi, I?m getting the following exception when I tried out ODB optimistic example First-chance exception at 0x751a812f in driver.exe: Microsoft C++ exception: odb::mssql::database_exception at memory location 0x0015e8ec.. I?ve replaced the 2 lines in person class header with ROWVERSION type. See below. //#pragma db version //unsigned long version_; #pragma db version type("ROWVERSION") unsigned long long version_; Here?s the line that the exception occurred. try { db->update (p2); // exception thrown here } catch (const object_changed&) { cout << "process 2 version is out of date: " << p2.version () << endl; // Reload the object and retry the operation. Note that the second // update call cannot throw object_changed since we reloaded the // object and are trying to update it in a single transaction. // db->reload (p2); cout << "process 2 version after reload: " << p2.version () << endl; p2.age (p2.age () + 1); db->update (p2); } I?m uisng VC++ 2008 Express and SQl Server 2008 Express on windows 7 32bits. Could you let me know whether I?m doing anything wrong? or is this a genuine problem in ODB? Thanks, Chew From boris at codesynthesis.com Sat May 18 12:49:19 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat May 18 12:47:59 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B6E55F@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6E55F@Gawain.dsonet.corp.root> Message-ID: Hi Chew, Chew Kok Keng writes: > First-chance exception at 0x751a812f in driver.exe: Microsoft C++ > exception: odb::mssql::database_exception at memory location 0x0015e8ec.. So the update() function throws odb::mssql::database_exception. It should have been caught and printed by the catch() handler on lines 153-157 in driver.cxx. Can you look at the output of the example and see what the exception says? Boris From boris at codesynthesis.com Sun May 19 20:29:08 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun May 19 20:27:49 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> Message-ID: Hi Chew, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Chew Kok Keng writes: > Here's the printed output > > version after persist: 2001 > process 1 version after load: 2001 > process 2 version after load: 2001 > process 1 version after update: 2002 > 0 (?????): result set expected from a statement with the OUTPUT clause I did some testing and it appears we have a bug here. I have implemented a fix and it would be great if you could try it and confirm that it works for you as well. Here is what you will need to do: 1. Download statement.cxx from here: http://codesynthesis.com/~boris/tmp/odb/statement.cxx 2. Copy it to libodb-mssql-2.2.0/odb/mssql/ (override the old file). 3. Rebuild libodb-mssql. 4. Rebuild the optimistic example. Once this is done, the example should work. Boris From tenchu.tarik at hotmail.fr Mon May 20 05:51:22 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Mon May 20 05:51:30 2013 Subject: [odb-users] Information Message-ID: Hello, I am currently using the odb framework. My IDE is visual studio 2012 and when I compile my project, first I have a lot of warnings : 1>warning C4068: unknown pragma and secondly, the compilation takes a while but the changes I've made are insignificant! Is it because I am not using correctly the odb tool or is it normal? Thank you for your help Tarik From mwpowellhtx at gmail.com Mon May 20 08:50:29 2013 From: mwpowellhtx at gmail.com (Michael Powell) Date: Mon May 20 08:50:36 2013 Subject: [odb-users] Question concerning cross compiling ODB Message-ID: Hello, I'm taking a look at ODB as a possible help to load and save objects persisted before, during, and after sessions (obviously). We've got an app that is cross compiled for Linux ARM architecture. If I understand properly, ODB hooks into the GCC in order to facilitate the code generation from the #pragmas embedded in the object model. We've got GCC 4.7.2 cross compilers for ARM, I use a toolchain from launchpad.net for "headless" (non-IDE) building, and the Sourcery CodeBench toolchain for IDE-enriched development. Possible to use ODB for this purpose? What sort of cross compile support is there out of the box if, say, we download the sources, configure, make, and build it? How to hook it in with GCC? May also have some observations about how to abstract transactions away from common ORM code as a "unit of work" design pattern, perhaps using C++ templates: i.e. template type thing, with common operations being begin, commit, rollback, type thing. Thank you... Regards, Michael Powell From ckokkeng at dso.org.sg Sun May 19 22:03:06 2013 From: ckokkeng at dso.org.sg (Chew Kok Keng) Date: Mon May 20 09:13:27 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> Message-ID: <20E19B3413064F4FA4771E0C05CAC4D4B6F58E@Gawain.dsonet.corp.root> Hi Boris, Pardon me for overlooking the odb-users mailing list. Appreciate your prompt reply. I'll try out as soon as I could. Thanks, Chew -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, May 20, 2013 8:29 AM To: Chew Kok Keng Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Optimistic Concurrency : ROWVERSION exception Hi Chew, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Chew Kok Keng writes: > Here's the printed output > > version after persist: 2001 > process 1 version after load: 2001 > process 2 version after load: 2001 > process 1 version after update: 2002 > 0 (?????): result set expected from a statement with the OUTPUT clause I did some testing and it appears we have a bug here. I have implemented a fix and it would be great if you could try it and confirm that it works for you as well. Here is what you will need to do: 1. Download statement.cxx from here: http://codesynthesis.com/~boris/tmp/odb/statement.cxx 2. Copy it to libodb-mssql-2.2.0/odb/mssql/ (override the old file). 3. Rebuild libodb-mssql. 4. Rebuild the optimistic example. Once this is done, the example should work. Boris From ckokkeng at dso.org.sg Mon May 20 09:43:53 2013 From: ckokkeng at dso.org.sg (Chew Kok Keng) Date: Mon May 20 10:09:07 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B6F58E@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> , <20E19B3413064F4FA4771E0C05CAC4D4B6F58E@Gawain.dsonet.corp.root> Message-ID: <20E19B3413064F4FA4771E0C05CAC4D4B715E4@Gawain.dsonet.corp.root> Hi Boris, The change did solve the exception. However, another exception appeared. This time it appears at line 103 db->update (p2). Here's the printed output and the code snippet. version after persist: 4003 process 1 version after load: 4003 process 2 version after load: 4003 process 1 version after update: 4004 process 2 version is out of date: 4003 process 2 version after reload: 4004 0 (24000): [Microsoft][SQL Server Native Client 10.0]Invalid cursor state try { db->update (p2); } catch (const object_changed&) { cout << "process 2 version is out of date: " << p2.version () << endl; // Reload the object and retry the operation. Note that the second // update call cannot throw object_changed since we reloaded the // object and are trying to update it in a single transaction. // db->reload (p2); cout << "process 2 version after reload: " << p2.version () << endl; p2.age (p2.age () + 1); db->update (p2); // Exception thrown here } Regards, Chew ________________________________________ From: Chew Kok Keng Sent: Monday, May 20, 2013 10:03 AM To: 'Boris Kolpackov' Cc: 'odb-users@codesynthesis.com' Subject: RE: [odb-users] Optimistic Concurrency : ROWVERSION exception Hi Boris, Pardon me for overlooking the odb-users mailing list. Appreciate your prompt reply. I'll try out as soon as I could. Thanks, Chew -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, May 20, 2013 8:29 AM To: Chew Kok Keng Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Optimistic Concurrency : ROWVERSION exception Hi Chew, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Chew Kok Keng writes: > Here's the printed output > > version after persist: 2001 > process 1 version after load: 2001 > process 2 version after load: 2001 > process 1 version after update: 2002 > 0 (?????): result set expected from a statement with the OUTPUT clause I did some testing and it appears we have a bug here. I have implemented a fix and it would be great if you could try it and confirm that it works for you as well. Here is what you will need to do: 1. Download statement.cxx from here: http://codesynthesis.com/~boris/tmp/odb/statement.cxx 2. Copy it to libodb-mssql-2.2.0/odb/mssql/ (override the old file). 3. Rebuild libodb-mssql. 4. Rebuild the optimistic example. Once this is done, the example should work. Boris From boris at codesynthesis.com Mon May 20 10:17:09 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 20 10:15:49 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B715E4@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B715E4@Gawain.dsonet.corp.root> Message-ID: Hi Chew, Chew Kok Keng writes: > 0 (24000): [Microsoft][SQL Server Native Client 10.0]Invalid cursor state Ok, I think I know what causes this one. Can you give this version of the fix a try? http://codesynthesis.com/~boris/tmp/odb/statement.cxx Boris From boris at codesynthesis.com Mon May 20 10:27:34 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 20 10:26:12 2013 Subject: [odb-users] Information In-Reply-To: References: Message-ID: Tarik BENZ writes: > My IDE is visual studio 2012 and when I compile my project, > first I have a lot of warnings : > 1>warning C4068: unknown pragma Section 12.8.2 in the manual describes various ways to get rid of these warnings. > and secondly, the compilation takes a while but the changes I've made > are insignificant! > > Is it because I am not using correctly the odb tool or is it normal? If you change one of the headers that define persistent classes, then they have to be recompiled with ODB and then the generated code has to be recompiled with VC++. Depending on the size of your project, this can take some time. It is also a good idea to make sure that your dependencies are set up correctly. One common sign that this is not the case is constant re- builds even without any changes. So a good test for this is to try to build the same project twice without making any changes in between. If everything is setup correctly, then for the second build the IDE should tell you that everything is up to date and not execute any commands. Finally, one way to speed up generated code compilation is to add the precompiled header to the generated source files. You can use the --cxx-prologue ODB compiler option to do this. Boris From boris at codesynthesis.com Mon May 20 10:42:16 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 20 10:40:55 2013 Subject: [odb-users] Question concerning cross compiling ODB In-Reply-To: References: Message-ID: Hi Michael, Michael Powell writes: > We've got an app that is cross compiled for Linux ARM architecture. If > I understand properly, ODB hooks into the GCC in order to facilitate > the code generation from the #pragmas embedded in the object model. Yes, this is correct. Note however, that the ODB compilation is a separate step and it doesn't have to use the same GCC (or, more generally, the same C++ compiler) as the one you use to build your applications. > We've got GCC 4.7.2 cross compilers for ARM, I use a toolchain from > launchpad.net for "headless" (non-IDE) building, and the Sourcery > CodeBench toolchain for IDE-enriched development. > > Possible to use ODB for this purpose? Yes, sure. > What sort of cross compile support is there out of the box if, say, > we download the sources, configure, make, and build it? How to hook > it in with GCC? The easiest way would be to use one of the pre-built ODB compiler binaries that include a private copy of GCC (happens to also be 4.7.2). We have a very detailed guide on how to cross-compile and use ODB for the Raspberry Pi target (which also happens to be ARM/Linux). > May also have some observations about how to abstract transactions > away from common ORM code as a "unit of work" design pattern, perhaps > using C++ templates: i.e. template type thing, with > common operations being begin, commit, rollback, type thing. I am not sure I understand what you are asking here. In ODB you don't need to have a reference to transaction in order to perform a database operation. Which means you can write code that just calls, say, load(), as long as you know that it will be called within a transaction. In other words: // Has to be called within a transaction. // void nested (odb::database& db) { ... shared_ptr o (db.load (id)); ... } transaction t (db.begin ()); nested (db); t.commit (); Boris From ckokkeng at dso.org.sg Mon May 20 11:22:54 2013 From: ckokkeng at dso.org.sg (Chew Kok Keng) Date: Mon May 20 12:43:36 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B715E4@Gawain.dsonet.corp.root>, Message-ID: <20E19B3413064F4FA4771E0C05CAC4D4B715F3@Gawain.dsonet.corp.root> Hi Boris, I've tried out the fixed and it worked fine. Thanks, Chew ________________________________________ From: Boris Kolpackov [boris@codesynthesis.com] Sent: Monday, May 20, 2013 10:17 PM To: Chew Kok Keng Cc: 'odb-users@codesynthesis.com' Subject: Re: [odb-users] Optimistic Concurrency : ROWVERSION exception Hi Chew, Chew Kok Keng writes: > 0 (24000): [Microsoft][SQL Server Native Client 10.0]Invalid cursor state Ok, I think I know what causes this one. Can you give this version of the fix a try? http://codesynthesis.com/~boris/tmp/odb/statement.cxx Boris From boris at codesynthesis.com Mon May 20 12:55:32 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 20 12:54:11 2013 Subject: [odb-users] Optimistic Concurrency : ROWVERSION exception In-Reply-To: <20E19B3413064F4FA4771E0C05CAC4D4B715F3@Gawain.dsonet.corp.root> References: <20E19B3413064F4FA4771E0C05CAC4D4B6CD54@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B6F570@Gawain.dsonet.corp.root> <20E19B3413064F4FA4771E0C05CAC4D4B715F3@Gawain.dsonet.corp.root> Message-ID: Hi Chew, Chew Kok Keng writes: > I've tried out the fixed and it worked fine. Thanks for confirming this. I will publish a bugfix release for libodb-mssql shortly. Boris From mwpowellhtx at gmail.com Tue May 21 08:06:57 2013 From: mwpowellhtx at gmail.com (Michael Powell) Date: Tue May 21 08:07:03 2013 Subject: [odb-users] Approaching the cross platform concern Message-ID: Hello, I've touched on it before, and forgive me, perhaps it is a cultural or language gap. My apologies if any of this is well covered in documentation I just haven't read yet. When we talk about cross compiling any code generating type helper, in this case for an ODB-supported C++ ORM, for ARM in our case, as far as ODB is concerned, there is the host platform where ORM glue code is generated. Then whatever cross compile toolchain for the target platform; we are using Sourcery CodeBench, but it's conceivable we will use some flavor of Qt toolchain somewhere in the loop as well. Must I configure and build the ODB library using both native and cross compile toolchains in order for this to work? So, potentially, we would end up with a couple of paths in our header and library paths: /path/to/odb/x86/include, /path/to/odb/x86/lib, /path/to/odb/arm/include, and so on. Assuming this is accurate, it is possible to build ODB to link statically, presumably through whatever intermediate glue code is generated? I am likely not clear what intermediate files are for code generation, versus which are for the target platform. At some point I'll move from asking questions to just doing it, but right now it's a bit fuzzy with me. Much appreciated. Regards, Michael Powell From mwpowellhtx at gmail.com Tue May 21 08:20:24 2013 From: mwpowellhtx at gmail.com (Michael Powell) Date: Tue May 21 08:20:30 2013 Subject: [odb-users] Handling the database versioning concern Message-ID: Hello, How does ODB handle the object and/or database versioning concern? Maybe a better question is, whether ODB does that? I'm sure the folks with C/S are well aware of this opportunity and the challenges involved. Hopefully when we design a database and an ORM the first time that's the only version we'll ever be concerned about. Sarcasm intentional. Obviously this is impractical to expect as new discoveries are made in the maturing of a given domain or model. One approach I've taken in the past, for example, with C# NHibernate and Fluent NHibernate, is to ensure that a set of ordered database updaters is run. Usually, in C# anyway, this ends up being composed and reflected out of a set of assemblies at run time. Updates only run when they need to, if, say, some version table reflects they need to, type thing. In C++-isms, that might be captured as a vector of these instances, or perhaps even a variadic template to capture the concern(s) more efficiently at compile time. I know Boris and folks dislike like the words framework or design pattern, also given that ODB supports several databases, does ODB provide any hooks in its object space to facilitate the versioning process? Even something like register these upgrade instances which consequently run embedded SQL statements to upgrade, type thing? Or perhaps more auto-magically generated than that? Thank you... Regards, Michael Powell From mwpowellhtx at gmail.com Tue May 21 08:28:07 2013 From: mwpowellhtx at gmail.com (Michael Powell) Date: Tue May 21 08:28:13 2013 Subject: [odb-users] Re: Handling the database versioning concern In-Reply-To: References: Message-ID: On Tue, May 21, 2013 at 7:20 AM, Michael Powell wrote: > Hello, > > How does ODB handle the object and/or database versioning concern? > Maybe a better question is, whether ODB does that? I'm sure the folks > with C/S are well aware of this opportunity and the challenges > involved. I'll also mention, I don't think this concern is necessarily a non-starter. Would be nice, but I believe there are ways to navigate that issue cross platform. Like we could design a version sniffer and expect end-users to run that C# .NET upgrader across platforms. Would involve copying databases over SCP, upgrading them, then redeploying them, type thing. Fairly doable in our set of tools for our purposes I think. > Hopefully when we design a database and an ORM the first time that's > the only version we'll ever be concerned about. Sarcasm intentional. > Obviously this is impractical to expect as new discoveries are made in > the maturing of a given domain or model. > > One approach I've taken in the past, for example, with C# NHibernate > and Fluent NHibernate, is to ensure that a set of ordered database > updaters is run. Usually, in C# anyway, this ends up being composed > and reflected out of a set of assemblies at run time. Updates only run > when they need to, if, say, some version table reflects they need to, > type thing. > > In C++-isms, that might be captured as a vector of these instances, or > perhaps even a variadic template to capture the concern(s) more > efficiently at compile time. > > I know Boris and folks dislike like the words framework or design > pattern, also given that ODB supports several databases, does ODB > provide any hooks in its object space to facilitate the versioning > process? Even something like register these upgrade instances which > consequently run embedded SQL statements to upgrade, type thing? Or > perhaps more auto-magically generated than that? > > Thank you... > > Regards, > > Michael Powell From benjamin.schudel at nexirius.com Tue May 21 08:03:18 2013 From: benjamin.schudel at nexirius.com (Benjamin Schudel) Date: Tue May 21 09:32:41 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows Message-ID: <1f8fc313117b598b2db1b2c597a545b5@mail.gmail.com> Hello, I have some problems to integrate the Multi-Database support in my application. The goal that I pursue is the possibility to switch between different database-systems at runtime (sqlite, mssql and mysql). At the moment the application supports only sqlite. I tried a lot of opportunities as described in the manual, without success. Is there a working example of a Multi-Database support application available? What I did: - 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) The source code compiled without changes, but during the first odb call I got an exception (Unhandled exception at 0x0033FE4B in Gui.exe: 0xC0000005: Access violation reading location 0x00000000.). The sourcecode looks like this (sqlite example - this code workes with single database compiled odb-files ): #include #include "User-odb.hxx" ? shared_ptr db (new odb::sqlite::database( "../../Bom1/bom1.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI)); typedef odb::query userQuery; typedef odb::result result; { odb::transaction t (db->begin ()); result user (db->query(userQuery::name == username)); ? t->commit (); } I tried a lot of other constellations e.g. typedef odb::sqlite::query userQuery; and odb::sqlite::transaction t (db->begin ()); but all ends with a compile error. What did I wrong? Can you send me a working example? - 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? Once I changed all generated files by hand , the source code compiled, but even in the static mode I didn?t get it to run. I included the "User-odb-sqlite.hxx" file instead of the "User-odb.hxx" file and tried again many different constellations, but it always ends in a compile error or in a Unhandled exception? The following modules I?m using: - libodb-2.2.2 - libodb-qt-2.2.0 - libodb-sqlite-2.2.0 - libodb-mssql-2.2.0 - libodb-mysql-2.2.0 I hope somebody can help me, and/or send me a complete, working example. Thanks in advance, Benjamin Schudel From hshmuelian at brilltech.com Tue May 21 09:38:56 2013 From: hshmuelian at brilltech.com (Herzl Shmuelian / Brilltech Int.) Date: Tue May 21 09:41:33 2013 Subject: [odb-users] how to use ODB for hight performance Message-ID: I am want use ODB for save huge msg that receive from my server this can be above 20K msg/per sec I try to use it but I have Performance problem, and when I try to check the performance by simple program like below: odb::mysql::database *pdb = new odb::mysql::database ("odb_test","","odb_test","127.0.0.1"); time_t t1; time_t t2; t1= time(0); transaction t(pdb->begin()); person jane ("222", "Doe", 32); for(unsigned int i = 0 ; i < 10000000 ; i++){ pdb->persist (jane); } t.comit(); t2= time(0); cout<<"time:"t<<2-t1< References: <1f8fc313117b598b2db1b2c597a545b5@mail.gmail.com> Message-ID: Hi Benjamin, Benjamin Schudel 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 From boris at codesynthesis.com Tue May 21 11:06:05 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 21 11:04:46 2013 Subject: [odb-users] how to use ODB for hight performance In-Reply-To: References: Message-ID: Hi Herzl, Herzl Shmuelian / Brilltech Int. writes: > I try to use it but I have Performance problem, and when I try to check the > performance by simple program like below: > > odb::mysql::database *pdb = new odb::mysql::database ( > "odb_test","","odb_test","127.0.0.1"); > time_t t1; > time_t t2; > t1= time(0); > transaction t(pdb->begin()); > person jane ("222", "Doe", 32); > for(unsigned int i = 0 ; i < 10000000 ; i++){ > pdb->persist (jane); > } > t.comit(); > t2= time(0); > cout<<"time:"t<<2-t1<begin()); person jane ("222", "Doe", 32); for(unsigned int i = 0 ; i < 10000000 ; i++) { if (i % 100 == 0) { t.commit (); t.reset (pdb->begin ()); } pdb->persist (jane); } t.commit(); Exactly how many objects to persist in each batch depends on your particular situation so it is a good idea to experiment with different sizes. > 1) open several connection to mysql ODB will do that if you request several connections at the same time. So if you can perform your persist() calls from multiple threads, then it may be worth a try. Before that, however, you may want to figure out what the bottleneck in your case is. For example, if the CPU utilization of your MySQL server is 100% then running persists from multiple threads won't do you any good. > 2) send several command together Are you referring to bulk INSERT here? If so, then MySQL doesn't support this feature. But if you use a database that supports it (e.g., Oracle or MS SQL), then, yes, that would definitely help. We plan to add ODB support for bulk INSERT for these databases in near future. > 3) unsync send commnad to mysql I maybe wrong, but I don't remember seeing any asynchronous statement execution support in the MySQL C API. Another option would be to switch to a different database. For example, I would expect SQLite, being an in-process database, to perform much better in this scenario. Boris From boris at codesynthesis.com Tue May 21 11:11:44 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 21 11:10:23 2013 Subject: [odb-users] Approaching the cross platform concern In-Reply-To: References: Message-ID: Hi Michael, Michael Powell writes: > Must I configure and build the ODB library using both native and cross > compile toolchains in order for this to work? You only need to build the ODB runtimes (libodb, libodb-) for the target (not host). I thought the guide that I referred to makes it quite clear. > Assuming this is accurate, it is possible to build ODB to link > statically, presumably through whatever intermediate glue code is > generated? Yes, it is possible. And again, the guide shows how to do exactly that. Have you read it? > At some point I'll move from asking questions to just doing it, but > right now it's a bit fuzzy with me. I think if you read the guide, things will become a lot clearer. In particular, it is not as complicated as you make it out to be: http://wiki.codesynthesis.com/Using_ODB_on_Mobile_and_Embedded_Systems Boris From boris at codesynthesis.com Tue May 21 11:19:22 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 21 11:18:01 2013 Subject: [odb-users] Handling the database versioning concern In-Reply-To: References: Message-ID: Hi Michael, Michael Powell writes: > How does ODB handle the object and/or database versioning concern? > Maybe a better question is, whether ODB does that? ODB will add fairly comprehensive database schema evolution support in the next release (expected around end-July). It will include automatic schema migration as well as support/hooks for data migration. In fact, most of it is already implemented and what's left is some loose ends and documentation. We will probably publish a beta before the final release if you would like to give it a try. Boris From boris at codesynthesis.com Tue May 21 13:39:25 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 21 13:38:04 2013 Subject: [odb-users] how to use ODB for hight performance In-Reply-To: References: Message-ID: Hi Herzl, Herzl Shmuelian / Brilltech Int. writes: > but when I add comment code "if (i % 100 == 0) etc" this decrease the > performace to 95 sec. > why this happend? As I said, the exact batch size that will result in optimal performance depends on your situations so it is a good ide to experiment with different sizes. Try 1000, 5,000, 10,000, etc. Or it could be that persisting 100,000 objects all at once it the best approach. Boris From sartor at oats.inaf.it Tue May 21 11:55:35 2013 From: sartor at oats.inaf.it (Stefano Sartor) Date: Tue May 21 13:38:31 2013 Subject: [odb-users] Segmentation fault when loading an unpersisted object through lazy_shared_ptr::load() Message-ID: <519B98F7.7050402@oats.inaf.it> Dear odb-users, I'm developing a library which wraps ODB and offers to the end users a simplified API. I use vectors of both lazy_shared_ptrs and lazy_weak_ptr for storing associations. The setters and getters in the attached code should provide an homogeneous access on the associations containers. Unfortunately, on transient objects, only the weak_objects() getter works because the lazy_weak_ptr::load() correctly detects that the weak_pointer is already initialized and returns the shared_ptr from the lock() method. The lazy_shared_ptr::load() instead of returning just the internal shared_ptr (on transient objects), always tries to load the object, causing a segmentation fault. I couldn't find any other way to get a shared_ptr from a lazy_shared_ptr. Note that I generate odb-files with --default-pointer std::tr1::shared_ptr. Some environment information: obd 2.2.1 libodb 2.2 libodb-mysql 2.2 libodb-boost 2.2 g++ 4.7.2 running on ubuntu 12.10 x86_64 best regards, Stefano -------------- next part -------------- A non-text attachment was scrubbed... Name: example.tar.gz Type: application/x-gzip Size: 10240 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20130521/aae6dc7f/example.tar.bin From hshmuelian at brilltech.com Tue May 21 12:25:20 2013 From: hshmuelian at brilltech.com (Herzl Shmuelian / Brilltech Int.) Date: Tue May 21 13:38:31 2013 Subject: [odb-users] how to use ODB for hight performance In-Reply-To: References: Message-ID: Hi Boris, thanks for your answer, I rty to change my code for sending from multiple threads like below unsigned __stdcall silly( void *arg ){ database *pdb = (database *)arg; person jane ("222", "Doe", 32); transaction t(pdb->begin()); for(unsigned int i = 0 ; i < 100000 ; i++){ pdb->persist (jane); /*if (i % 100 == 0){ t.commit (); t.reset (pdb->begin ()); }*/ t.commit(); } return 1; } int main (int argc, char* argv[]) { { HANDLE hThread[10]; unsigned threadID; database *pdb = (new odb::mysql::database ("odb_test","","odb_test","127.0.0.1")); time_t t1,t2; t1 = time(0); for(unsigned int i = 0 ; i < 10 ; i++) hThread[i] = (HANDLE)_beginthreadex( NULL, 0, &silly, pdb, 0, &threadID ); for(unsigned int i = 0 ; i < 10 ; i++) WaitForSingleObject( hThread[i], INFINITE ); t2 = time(0); cout<<"time:"<wrote: > Hi Herzl, > > Herzl Shmuelian / Brilltech Int. writes: > > > I try to use it but I have Performance problem, and when I try to check > the > > performance by simple program like below: > > > > odb::mysql::database *pdb = new odb::mysql::database ( > > "odb_test","","odb_test","127.0.0.1"); > > time_t t1; > > time_t t2; > > t1= time(0); > > transaction t(pdb->begin()); > > person jane ("222", "Doe", 32); > > for(unsigned int i = 0 ; i < 10000000 ; i++){ > > pdb->persist (jane); > > } > > t.comit(); > > t2= time(0); > > cout<<"time:"t<<2-t1< > One sure way to improve the performance of the above transaction is to > split it into multiple batches. Persisting 1M of objects in a single > transaction will definitely be slow. > > Here is an example (taken from the manual): > > transaction t(pdb->begin()); > person jane ("222", "Doe", 32); > > for(unsigned int i = 0 ; i < 10000000 ; i++) > { > if (i % 100 == 0) > { > t.commit (); > t.reset (pdb->begin ()); > } > > pdb->persist (jane); > } > > t.commit(); > > Exactly how many objects to persist in each batch depends on your > particular situation so it is a good idea to experiment with > different sizes. > > > > 1) open several connection to mysql > > ODB will do that if you request several connections at the same time. > So if you can perform your persist() calls from multiple threads, then > it may be worth a try. Before that, however, you may want to figure out > what the bottleneck in your case is. For example, if the CPU utilization > of your MySQL server is 100% then running persists from multiple threads > won't do you any good. > > > > 2) send several command together > > Are you referring to bulk INSERT here? If so, then MySQL doesn't support > this feature. But if you use a database that supports it (e.g., Oracle or > MS SQL), then, yes, that would definitely help. We plan to add ODB support > for bulk INSERT for these databases in near future. > > > > 3) unsync send commnad to mysql > > I maybe wrong, but I don't remember seeing any asynchronous statement > execution support in the MySQL C API. > > Another option would be to switch to a different database. For example, > I would expect SQLite, being an in-process database, to perform much > better in this scenario. > > Boris > From boris at codesynthesis.com Tue May 21 19:30:37 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 21 19:29:18 2013 Subject: [odb-users] Segmentation fault when loading an unpersisted object through lazy_shared_ptr::load() In-Reply-To: <519B98F7.7050402@oats.inaf.it> References: <519B98F7.7050402@oats.inaf.it> Message-ID: Hi Stefano, Stefano Sartor writes: > Unfortunately, on transient objects, only the weak_objects() getter > works because the lazy_weak_ptr::load() correctly detects that the > weak_pointer is already initialized and returns the shared_ptr from the > lock() method. > > The lazy_shared_ptr::load() instead of returning just the internal > shared_ptr (on transient objects), always tries to load the object, > causing a segmentation fault. > > I couldn't find any other way to get a shared_ptr from a lazy_shared_ptr. Currently, we expect load() to only be called on persistent objects. Also, as you found out, while it is possible to detect whether the object is persistent, there is no way to get the underlying eager pointer. I've fixed both of these issues. load() will now ignore attempts to load transient objects. Here is the patch for libodb: http://scm.codesynthesis.com/?p=odb/libodb.git;a=patch;h=6c666b0dfa38cf1f6407817261a829645e86d855 I've also added the get_eager() function to all the lazy pointers provided by ODB that returns the underlying eager pointer. Here is the patch, again, for libodb: http://scm.codesynthesis.com/?p=odb/libodb.git;a=patch;h=fb2519f6f9d79c7626a0281ad24925b4976cd81d There are also similar patches for libodb-boost and libodb-qt. Let me know if you find any issues with these changes. Boris From boris at codesynthesis.com Wed May 22 21:58:15 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 22 21:57:03 2013 Subject: [odb-users] how to use ODB for hight performance In-Reply-To: References: Message-ID: Hi Herzl, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Herzl Shmuelian / Brilltech Int. writes: > 1) I check in wireshark and for each persistence (statement mysql cliet > send a tcp paket and wait reponse) > if exist option to send some statement together in a tcp packet? Not in ODB. MySQL allows you to execute several statements at once and it is possible (I don't know for certain) that in this case MySQL will send them in a single packet. However, I am pretty sure this feature is incompatible with prepared statements, which ODB uses throughout. In fact, I believe using prepared statements is a bigger advantage compared to multiple statement execution. Boris From benjamin.schudel at nexirius.com Thu May 23 08:52:21 2013 From: benjamin.schudel at nexirius.com (Benjamin Schudel) Date: Thu May 23 09:04:42 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows Message-ID: 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 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' (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::query(odb::database & db, const odb::query_base & q) Line 93 C++ Gui.exe!odb::database::query_::call>(odb::database & db, const odb::query & q) Line 115C++ Gui.exe!odb::database::query(const odb::query& 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@codesynthesis.com]Gesendet: Dienstag, 21. Mai 2013 16:04An: Benjamin SchudelCc: odb-users@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 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 From boris at codesynthesis.com Thu May 23 09:10:44 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 23 09:09:29 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: Message-ID: Hi Benjamin, Benjamin Schudel writes: > 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). Can you send me the definition of the BaseBO class (and maybe one of its derived classes as well, e.g., User)? Or, better yet, a small but complete test that reproduces the problem. Boris From benjamin.schudel at nexirius.com Thu May 23 09:44:55 2013 From: benjamin.schudel at nexirius.com (Benjamin Schudel) Date: Thu May 23 18:26:21 2013 Subject: AW: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: Message-ID: Hi Boris, you will find the classes as attachments. Thanks in advance, Benjamin -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Donnerstag, 23. Mai 2013 15:11 An: Benjamin Schudel Cc: odb-users@codesynthesis.com Betreff: Re: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows Hi Benjamin, Benjamin Schudel writes: > 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). Can you send me the definition of the BaseBO class (and maybe one of its derived classes as well, e.g., User)? Or, better yet, a small but complete test that reproduces the problem. Boris -------------- next part -------------- /////////////////////////////////////////////////////////// // User.h // Implementation of the Class User // Created on: 29-Nov-2012 18:20:21 // Original author: David Posva /////////////////////////////////////////////////////////// #if !defined(EA_0FA84639_6280_4cf2_B369_4E88785C6532__INCLUDED_) #define EA_0FA84639_6280_4cf2_B369_4E88785C6532__INCLUDED_ #include "BaseBO.h" #include "UserGroup.h" #include #ifndef ODB_COMPILER #include "LogManager.h" #include "DatabaseManager.h" #endif //#pragma db value(QString) type("VARCHAR") #pragma db object pointer(shared_ptr) #pragma db object optimistic class User : #ifndef ODB_COMPILER public std::enable_shared_from_this< User >, #endif public BaseBO { public: User(); User(QString name, QString password); virtual ~User(); vector > getGroups() const; void setGroups(vector > val); QString getName() const; void setName(QString val); QString getPassword() const; void setPassword(QString val); virtual void save(); virtual void remove(); private: friend class odb::access; vector > groups; QString name; QString password; #ifndef ODB_COMPILER #pragma db transient shared_ptr log; #pragma db transient shared_ptr dbManager; #endif }; #endif // !defined(EA_0FA84639_6280_4cf2_B369_4E88785C6532__INCLUDED_) -------------- next part -------------- /////////////////////////////////////////////////////////// // BaseBO.h // Implementation of the Class BaseBO // Created on: 27-Nov-2012 18:49:06 // Original author: David Posva /////////////////////////////////////////////////////////// #if !defined(EA_741592B4_4C31_44b7_9FD1_A2299286834F__INCLUDED_) #define EA_741592B4_4C31_44b7_9FD1_A2299286834F__INCLUDED_ #define NOMINMAX #include "BoIF.h" #ifndef ODB_COMPILER #include "Uuid.h" #include "LogManager.h" #include "ObjectSerializeContainerIF.h" #endif #ifdef ODB_COMPILER #include #endif #include #include #include #include #include //#include using std::tr1::shared_ptr; //using std::shared_ptr; using std::vector; using std::cerr; //using odb::tr1::lazy_shared_ptr; //no odb lazy loading -> use hand made delayed loading, so it works also with detached objects //#pragma warning (push) //#pragma warning (disable:4068) //#pragma db value(Uuid) type("VARCHAR") #pragma db value(QString) type("VARCHAR") mysql:type("VARCHAR(100)") #pragma db value(QDateTime) type("DATETIME") sqlite:type("TEXT") // #pragma db object /*pointer(*)*/ abstract #pragma db object optimistic /** * Base implementation of all Business Objects. */ /*abstract*/ class BaseBO : public BoIF { friend class BoLoaderFactory; protected: //BaseBO(Uuid id); public: BaseBO(); virtual ~BaseBO(); #ifndef ODB_COMPILER #pragma db transient virtual void serialize(ObjectSerializeContainerIF* output); //impl BoIF virtual void deserialize(ObjectSerializeContainerIF* input); //impl BoIF virtual void save() = 0; virtual void remove() = 0; #endif //#pragma db transient //virtual QString toString(); //TODO ref to db connection / bo source //not via singleton to DbConnection => to be able to have more than one BO sources in one application /** * The ID for the BO. * Consisting of a random UUID - with first 3 chars for the class identifier. */ virtual QString get_id() const; //impl BoIF //lazy initializer -> fixing the "wrong type in base c'tor" issue - and saving some time if never used void setReadOnly(bool readOnly); bool getReadOnly(); void setPersistable(bool persistable); bool getPersistable(); void setPersisted(bool persisted); bool getPersisted(); void setDeleted(bool deleted); bool getDeleted(); void setCreationDate(QDateTime creationDate); QDateTime getCreationDate(); void setCreationUser(QString creationUser); QString getCreationUser(); void setModificationDate(QDateTime modificationDate); QDateTime getModificationDate(); void setModificationUser(QString modificationUser); QString getModificationUser(); int getVersionNr(); private: friend class odb::access; /** * Random UUID - with first 3 chars for the class identifier. */ #pragma db id type("VARCHAR") mysql:type("VARCHAR(100)") #pragma db get(get_id) // Uses by-reference modifier. mutable QString id; //UUId-String from Uuid::createUuidString() bool readOnly; /** * Can be stored into the DB. (see also persisted & deleted) * BOs that should get written into the DB (due to no mapping to a table or because they are just temporary) should get constructed with false. */ bool persistable; /** * is already in the DB */ bool persisted; bool deleted; /** * -> does also set the modificationDate (if that is null) */ QDateTime creationDate; /** * "weak" reference to the user - via name not via userId. * -> does also set the modificationUser (if that is null) */ QString creationUser; /** * is >= creationDate = never null */ QDateTime modificationDate; /** * "weak" reference to the user - via name not via userId. * if modificationDate == creationDate -> modificationUser == creationUser */ QString modificationUser; /** * Used to compare if the version in the DB is the one that was loaded. * Will be automatically incremented everytime it is stored. See Chapter 11 "Optimistic Concurrency" #pragma db version * If the version isn't the same as the one in memory a reload is needed & a save must be prohibited. * (= someone else was faster with changing and writing the data => odb::object_changed exception - "catch (const object_changed&)") * The initialization and increment is managed by ODB. A value of 0 means = not saved yet / transient. * ! Don't change this value in business logic!!! */ #pragma db version const unsigned int versionNr; //!const is NOT forced by ODB: see chapter 11 Optimistic Concurrency ///*abstract*/ list* getProperties(); #ifndef ODB_COMPILER #pragma db transient shared_ptr log; #endif }; #endif // !defined(EA_741592B4_4C31_44b7_9FD1_A2299286834F__INCLUDED_) -------------- next part -------------- /////////////////////////////////////////////////////////// // BaseBO.cpp // Implementation of the Class BaseBO // Created on: 29-Nov-2012 18:20:07 // Original author: David Posva /////////////////////////////////////////////////////////// #include "BaseBO.h" #include "Uuid.h" #include "ObjectSerializeContainerIF.h" #include "Exception.h" //BaseBO::BaseBO(Uuid existingId){ // idx = existingId; //} //QString BaseBO::toString(){ // return QString::number(idx); //} BaseBO::BaseBO() ://id(Uuid::createUuidString(QString(typeid(this).name()))), creationDate(QDateTime::currentDateTime()), modificationDate(QDateTime::currentDateTime()), creationUser(QString("me")), modificationUser(QString("me")), versionNr(0), persisted(false), deleted(false) { log = LogManager::getCentralInstance(); } BaseBO::~BaseBO(){ } void BaseBO::serialize(ObjectSerializeContainerIF* output) { log->log(QString("BaseBO::serialize").append(" type: ").append(typeid(*this).name())); output->writeAttribute("id",get_id(),true); output->writeAttribute("readOnly",readOnly); output->writeAttribute("persistable",persistable); output->writeAttribute("persisted",persisted); output->writeAttribute("deleted",deleted); output->writeAttribute("creationDate",creationDate); output->writeAttribute("creationUser",creationUser); output->writeAttribute("modificationDate",modificationDate); output->writeAttribute("modificationUser",modificationUser); output->writeAttribute("versionNr",versionNr); } void BaseBO::deserialize(ObjectSerializeContainerIF* input){ log->log(QString("BaseBO::deserialize").append(" type: ").append(typeid(*this).name())); this->id = input->readAttribute("id"); this->readOnly = input->readAttributeBool("readOnly"); this->persistable = input->readAttributeBool("persistable"); this->persisted = input->readAttributeBool("persisted"); this->deleted = input->readAttributeBool("deleted"); this->creationDate = input->readAttributeQDateTime("creationDate"); this->creationUser = input->readAttribute("creationUser"); this->modificationDate = input->readAttributeQDateTime("modificationDate"); this->modificationUser = input->readAttribute("modificationUser"); //TODO check does this work?! this->versionNr const_cast - !const is NOT forced by ODB, but suggested: see chapter 11 Optimistic Concurrency //http://stackoverflow.com/questions/583076/c-c-changing-the-value-of-a-const //http://stackoverflow.com/questions/357600/is-const-cast-safe //http://www.cplusplus.com/forum/general/17155/ unsigned int versionNrDeserialized = input->readAttributeUInt("versionNr"); //log->log(this->versionNr); //log->log(versionNrDeserialized); unsigned int * versionNr_Ptr = const_cast (&this->versionNr); *versionNr_Ptr = versionNrDeserialized; //log->log(this->versionNr); //it seems to work with M$-VisualStudio compiler... } void BaseBO::save(){ throw new Exception("BaseBO::save not implemented!"); } void BaseBO::remove(){ throw new Exception("BaseBO::remove not implemented!"); } QString BaseBO::get_id() const { //lazy initializer -> fixing the "wrong type in base c'tor" (type is always BaseBO) issue - and saving some time if never used // - with id / UUID generation in BaseBO we had: "!derived classes have to overload empty c'tor including idx = Uuid::createUuidString(idx,QString(typeid(this).name())); because the typeid(this) in the baseBO is still BaseBO and not the later type!" if (id.length()==0) { log->log("id old"); log->log(id); //mutable QString id; -> nicht mehr n?tig: const_cast(this)->id = Uuid::createUuidString(QString(typeid(*this).name())); //id = Uuid::createUuidString(QString(typeid(*this).name())); id = Uuid::createUuidString(QString(typeid(*this).name())); log->log("id new"); log->log(id); } return id; } void BaseBO::setReadOnly( bool readOnly ) { this->readOnly = readOnly; } bool BaseBO::getReadOnly() { return this->readOnly; } void BaseBO::setPersistable( bool persistable ) { this->persistable = persistable; } bool BaseBO::getPersistable() { return this->persistable; } void BaseBO::setPersisted( bool persisted ) { this->persisted = persisted; } bool BaseBO::getPersisted() { return this->persisted; } void BaseBO::setDeleted( bool deleted ) { this->deleted = deleted; } bool BaseBO::getDeleted() { return this->deleted; } void BaseBO::setCreationDate( QDateTime creationDate ) { this->creationDate = creationDate; } QDateTime BaseBO::getCreationDate() { return this->creationDate; } void BaseBO::setCreationUser( QString creationUser ) { this->creationUser = creationUser; } QString BaseBO::getCreationUser() { return this->creationUser; } void BaseBO::setModificationDate( QDateTime modificationDate ) { this->modificationDate = modificationDate; } QDateTime BaseBO::getModificationDate() { return this->modificationDate; } void BaseBO::setModificationUser( QString modificationUser ) { this->modificationUser = modificationUser; } QString BaseBO::getModificationUser() { return this->modificationUser; } int BaseBO::getVersionNr() { return this->versionNr; } //list* BaseBO::getProperties(){ // return new list(); //} -------------- next part -------------- /////////////////////////////////////////////////////////// // User.cpp // Implementation of the Class User // Created on: 29-Nov-2012 18:20:21 // Original author: David Posva /////////////////////////////////////////////////////////// #include "User.h" #include "User-odb.hxx" #include "Transaction.h" #include "Exception.h" #include "SoapServiceManager.h" User::User(){ log = LogManager::getCentralInstance(); dbManager = DatabaseManager::getUniqueInstance(); } User::User(QString name, QString password) : name(name), password(password){ log = LogManager::getCentralInstance(); dbManager = DatabaseManager::getUniqueInstance(); } User::~User(){ } void User::save(){ try { if (SettingsManager::getUniqueInstance()->getDirectDbConnection()) { log->log(QString("Persist User. -> direct in DB")); shared_ptr db (dbManager->openDatabaseConnection()); Transaction t(db); if(this->getPersisted()) { db->update(*this); } else { this->setPersisted(true); db->persist(*this); } t.commit(); log->log(QString("User persisted")); } else { log->log(QString("Persist User. -> via SOAP")); SoapServiceManager::getUniqueInstance()->doBusinessTask(this->shared_from_this(), "save"); } } catch (const Exception& e) { cerr << e.what() << endl; log->log("save User Exception: "); log->log(e.getProblem()); } catch (const odb::exception& e) { cerr << e.what() << endl; log->log("save User Exception: "); log->log(e.what()); } catch (const std::exception& e) { cerr << e.what() << endl; log->log("save User Exception: "); log->log(e.what()); } } void User::remove() { try { if (SettingsManager::getUniqueInstance()->getDirectDbConnection()) { shared_ptr db (dbManager->openDatabaseConnection()); Transaction t(db); log->log(QString("Remove User. -> direct in DB")); db->erase(*this); t.commit(); } else{ log->log(QString("Remove User. -> via SOAP")); SoapServiceManager::getUniqueInstance()->doBusinessTask(this->shared_from_this(), "remove"); } } catch (const Exception& e) { cerr << e.what() << endl; log->log("remove User Exception: "); log->log(e.getProblem()); } catch (const odb::exception& e) { cerr << e.what() << endl; log->log("remove User Exception: "); log->log(e.what()); } catch (const std::exception& e) { cerr << e.what() << endl; log->log("remove User Exception: "); log->log(e.what()); } } vector > User::getGroups() const { return groups; } void User::setGroups( vector > val ) { groups = val; } QString User::getName() const { return name; } void User::setName( QString val ) { name = val; } QString User::getPassword() const { return password; } void User::setPassword( QString val ) { password = val; } From boris at codesynthesis.com Fri May 24 07:39:30 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 24 07:38:14 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: Message-ID: Hi Benjamin, Benjamin Schudel writes: > template > 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' > (ODBGenerated\BaseBO-odb-mssql.cxx) I could reproduce this on my side and it is a bug in the ODB compiler. I will work on the fix and get back to you. A simple workaround for now is not to declare your BaseBO class as abstract. You will end up an extra table in the database, but otherwise this change should be harmless. > I guess it has never been initialized correctly? Hm, this is strange. I tried it on my side, and I see things initialized. Can you make sure that you do all of the following: 1. You generate User-odb-mssql.cxx. 2. You generate User-odb-mssql.cxx with query support enabled (-q/--generate-query). 3. You actually link User-odb-mssql.cxx to your application. Be careful if User-odb-mssql.cxx is packaged into a static library -- in this case it may be ignored. If you do all of the above, check User-odb-mssql.cxx. You should see code like this at the end of the file: static const access::object_traits_impl< ::User, id_common >:: function_table_type function_table_User_ = { &access::object_traits_impl< ::User, id_mssql >::persist, &access::object_traits_impl< ::User, id_mssql >::find, &access::object_traits_impl< ::User, id_mssql >::find, &access::object_traits_impl< ::User, id_mssql >::reload, &access::object_traits_impl< ::User, id_mssql >::update, &access::object_traits_impl< ::User, id_mssql >::erase, &access::object_traits_impl< ::User, id_mssql >::erase, &access::object_traits_impl< ::User, id_mssql >::query, &access::object_traits_impl< ::User, id_mssql >::erase_query }; static const object_function_table_entry< ::User, id_mssql > function_table_entry_User_ ( &function_table_User_); Boris From boris at codesynthesis.com Sat May 25 12:12:02 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat May 25 12:10:46 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: Message-ID: Hi Benjamin, Boris Kolpackov writes: > Benjamin Schudel writes: > > > error C2039: 'table_name' : is not a member of > > 'odb::access::object_traits_impl' > > (ODBGenerated\BaseBO-odb-mssql.cxx) > > I could reproduce this on my side and it is a bug in the ODB compiler. > I will work on the fix and get back to you. Ok, I've fixed this bug. If you would like, I can build you the ODB compiler binary with the fix to try. Boris From benjamin.schudel at nexirius.com Mon May 27 07:16:41 2013 From: benjamin.schudel at nexirius.com (Benjamin Schudel) Date: Mon May 27 09:19:11 2013 Subject: AW: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: Message-ID: <397f68832614c88278f47a69216512a2@mail.gmail.com> Hi Boris, thanks for your fast reaction. It would be nice, if you could send me the new ODB compiler. Regards Benjamin -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Samstag, 25. Mai 2013 18:12 An: Benjamin Schudel Cc: odb-users@codesynthesis.com Betreff: Re: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows Hi Benjamin, Boris Kolpackov writes: > Benjamin Schudel writes: > > > error C2039: 'table_name' : is not a member of > > 'odb::access::object_traits_impl' > > (ODBGenerated\BaseBO-odb-mssql.cxx) > > I could reproduce this on my side and it is a bug in the ODB compiler. > I will work on the fix and get back to you. Ok, I've fixed this bug. If you would like, I can build you the ODB compiler binary with the fix to try. Boris From boris at codesynthesis.com Mon May 27 10:50:16 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 27 10:49:00 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: <397f68832614c88278f47a69216512a2@mail.gmail.com> References: <397f68832614c88278f47a69216512a2@mail.gmail.com> Message-ID: Hi Benjamin, Benjamin Schudel writes: > It would be nice, if you could send me the new ODB compiler. Here it is. Let me know if there are still any issues: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.2.2-i686-windows.zip Also, I assume you've managed to resolve your other issue with uninitialized function tables? Boris From benjamin.schudel at nexirius.com Tue May 28 08:41:02 2013 From: benjamin.schudel at nexirius.com (Benjamin Schudel) Date: Tue May 28 09:43:16 2013 Subject: AW: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: <397f68832614c88278f47a69216512a2@mail.gmail.com> Message-ID: <474d4ff11b4d265ca7af9a228ec04d24@mail.gmail.com> Hi Boris, with the new ODB-compiler the error is fixed as you said. But I still get the Unhandled exception which occurs on the User-odb.ixx-file. 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); } You said I should be careful if User-odb-mssql.cxx is packaged into a static library... What do you exactly mean with that? Because all odb generated files are packaged into a static library in my vs-solution. Could that be the reason for the exception? By the way, the bug I reported in the first mail still occurs: If I run the following command, all .hxx files have two #include-statements on the same line (which ends in a compile error)... even with the new compiler version odb.exe -m dynamic -d common -d sqlite -d mysql -d mssql -I C:\Qt\qt-5.0.1-32-dyn\qtbase\include --profile qt --generate-query *.h E.g. the User-odb-mssql.hxx looks like this: ... #include "Role-odb-mssql.hxx" #include "UserGroup-odb-mssql.hxx"#include "User-odb.hxx" #include ... Thanks and regards, Benjamin -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Montag, 27. Mai 2013 16:50 An: Benjamin Schudel Cc: odb-users@codesynthesis.com Betreff: Re: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows Hi Benjamin, Benjamin Schudel writes: > It would be nice, if you could send me the new ODB compiler. Here it is. Let me know if there are still any issues: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.2.2-i686-windows.zip Also, I assume you've managed to resolve your other issue with uninitialized function tables? Boris From boris at codesynthesis.com Tue May 28 10:24:16 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 28 10:23:00 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: <474d4ff11b4d265ca7af9a228ec04d24@mail.gmail.com> References: <397f68832614c88278f47a69216512a2@mail.gmail.com> <474d4ff11b4d265ca7af9a228ec04d24@mail.gmail.com> Message-ID: Hi Benjamin, Benjamin Schudel writes: > But I still get the Unhandled exception which occurs on the > User-odb.ixx-file. > > [...] > > You said I should be careful if User-odb-mssql.cxx is packaged into a > static library... What do you exactly mean with that? When using a static library (.lib on Windows and .a on Linux/UNIX), the linker will only link an object file from this library if it contains a symbol that is referenced from the executable. If, however, the object file within a library is not referenced, then it will be ignored. And that's exactly what can happen in dynamic multi-database support since you don't reference database-specific symbols from your code. Rather, you work through the common interface. On Linux, GNU ld has the --whole-archive option which can be used to override this behavior. Unfortunately, there is nothing like this in VC++. > Because all odb generated files are packaged into a static library in my > vs-solution. Could that be the reason for the exception? Yes, I am pretty sure this is the cause of the exception. In your case the easiest option is probably to add the generated code directly to the executable rather than packaging it into a static library. > By the way, the bug I reported in the first mail still occurs: > > [...] > > #include "UserGroup-odb-mssql.hxx"#include "User-odb.hxx" Sorry, I must have missed it. I've uploaded an updated revision of the 2.2.0 binary that should fix this: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.2.2-i686-windows.zip Boris From contact at rkade.fr Wed May 29 07:43:11 2013 From: contact at rkade.fr (rkadeFR) Date: Wed May 29 07:43:15 2013 Subject: [odb-users] Create odb class from sql schema / use an existent database Message-ID: <51A5E9CF.7050804@rkade.fr> I did some research and didn't find any answer. If I'm wrong, please just indicate the thread/email/url. I have an existent DB, and would like to map it to some C++/ODB classes in order to use my DB. Is there a possibility to generate the C++/ODB classes? Or is there an efficient way for me using an existing DB with my C++ program? thank you From DThroop at PacificCabinets.com Wed May 29 09:33:47 2013 From: DThroop at PacificCabinets.com (Dean Throop) Date: Wed May 29 09:34:15 2013 Subject: [odb-users] Create odb class from sql schema / use an existent database Message-ID: Hi rkadeFR, It is straightforward to work with an existing database. You basically follow the same strategies and instructions. There is not a way to generate the ODB classes from the existing schema. You will need to extend your classes with the necessary ODB items (pragmas, queries, etc.). Some things that helped me when I started...start small to figure out some of the details and validate it is working properly, and even though you already have an existing database have the compiler generate the schema so you can compare what ODB thinks you need vs. what you already have. Dean rkadeFR wrote: I did some research and didn't find any answer. If I'm wrong, please just indicate the thread/email/url. I have an existent DB, and would like to map it to some C++/ODB classes in order to use my DB. Is there a possibility to generate the C++/ODB classes? Or is there an efficient way for me using an existing DB with my C++ program? thank you From benjamin.schudel at nexirius.com Wed May 29 09:58:49 2013 From: benjamin.schudel at nexirius.com (Benjamin Schudel) Date: Wed May 29 10:01:30 2013 Subject: AW: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: <397f68832614c88278f47a69216512a2@mail.gmail.com> <474d4ff11b4d265ca7af9a228ec04d24@mail.gmail.com> Message-ID: Hi Boris, The multi database support seems to work now. It was the static library issue, as you said. I could fix the problem with two changes on the Linker-Settings of the executable project. I found out when you set the property "Use Library Dependency Inputs" to "true" and "References" to "No (/OPT:NOREF)", you can keep the odb-files into the static library package. Thank you for the help, regards Benjamin -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Dienstag, 28. Mai 2013 16:24 An: Benjamin Schudel Cc: odb-users@codesynthesis.com Betreff: Re: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows Hi Benjamin, Benjamin Schudel writes: > But I still get the Unhandled exception which occurs on the > User-odb.ixx-file. > > [...] > > You said I should be careful if User-odb-mssql.cxx is packaged into a > static library... What do you exactly mean with that? When using a static library (.lib on Windows and .a on Linux/UNIX), the linker will only link an object file from this library if it contains a symbol that is referenced from the executable. If, however, the object file within a library is not referenced, then it will be ignored. And that's exactly what can happen in dynamic multi-database support since you don't reference database-specific symbols from your code. Rather, you work through the common interface. On Linux, GNU ld has the --whole-archive option which can be used to override this behavior. Unfortunately, there is nothing like this in VC++. > Because all odb generated files are packaged into a static library in > my vs-solution. Could that be the reason for the exception? Yes, I am pretty sure this is the cause of the exception. In your case the easiest option is probably to add the generated code directly to the executable rather than packaging it into a static library. > By the way, the bug I reported in the first mail still occurs: > > [...] > > #include "UserGroup-odb-mssql.hxx"#include "User-odb.hxx" Sorry, I must have missed it. I've uploaded an updated revision of the 2.2.0 binary that should fix this: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.2.2-i686-windows.zip Boris From boris at codesynthesis.com Wed May 29 10:06:21 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 29 10:05:03 2013 Subject: [odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows In-Reply-To: References: <397f68832614c88278f47a69216512a2@mail.gmail.com> <474d4ff11b4d265ca7af9a228ec04d24@mail.gmail.com> Message-ID: Hi Benjamin, Benjamin Schudel writes: > I could fix the problem with two changes on the Linker-Settings of the > executable project. > I found out when you set the property "Use Library Dependency Inputs" to > "true" and "References" to "No (/OPT:NOREF)", you can keep the odb-files > into the static library package. Great, thanks for sharing this! I read about the /OPT:NOREF though from the feedback on the internet it didn't seem to work reliably. Perhaps that second change is what makes everything work. Boris From boris at codesynthesis.com Wed May 29 08:27:22 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 29 11:06:53 2013 Subject: [odb-users] Create odb class from sql schema / use an existent database In-Reply-To: <51A5E9CF.7050804@rkade.fr> References: <51A5E9CF.7050804@rkade.fr> Message-ID: Hi, rkadeFR writes: > I have an existent DB, and would like to map it to > some C++/ODB classes in order to use my DB. > > Is there a possibility to generate the C++/ODB classes? Currently, there is no support for automatically generating C++ classes from database schema. But seeing that this feature is requested a lot, we are planning to add this support soon. I your case, would you prefer the C++ classes generated from a .sql file containing your table definitions or by connecting to the database directly? > Or is there an efficient way for me using an existing DB > with my C++ program? Right now, if you want to use ODB with an existing database, then you will need to create and map your C++ classes manually. ODB allows you to map to custom tables, columns, and database types, for example: #pragma db table("PEOPLE") class person { ... #pragma db column("NAME") type("VARCHAR(50)") std::string name; }; There is also the 'schema/custom' example in the odb-examples package that shows how to do it. Boris From contact at rkade.fr Wed May 29 12:01:25 2013 From: contact at rkade.fr (rkadeFR) Date: Wed May 29 12:01:29 2013 Subject: [odb-users] Create odb class from sql schema / use an existent database In-Reply-To: References: <51A5E9CF.7050804@rkade.fr> Message-ID: <51A62655.3020202@rkade.fr> On 29/05/2013 14:27, Boris Kolpackov wrote: > Hi, > > rkadeFR writes: > >> I have an existent DB, and would like to map it to >> some C++/ODB classes in order to use my DB. >> >> Is there a possibility to generate the C++/ODB classes? > Currently, there is no support for automatically generating > C++ classes from database schema. But seeing that this feature > is requested a lot, we are planning to add this support soon. > > I your case, would you prefer the C++ classes generated > from a .sql file containing your table definitions or by > connecting to the database directly? I would rather have them generated from a .sql. I don't have the database, but can have the dump of the schema. > >> Or is there an efficient way for me using an existing DB >> with my C++ program? > Right now, if you want to use ODB with an existing database, > then you will need to create and map your C++ classes manually. > ODB allows you to map to custom tables, columns, and database > types, for example: > > #pragma db table("PEOPLE") > class person > { > ... > > #pragma db column("NAME") type("VARCHAR(50)") > std::string name; > }; > > There is also the 'schema/custom' example in the odb-examples package > that shows how to do it. > > Boris That's such a great feature ! Thank you for your quick answer From contact at rkade.fr Thu May 30 04:59:08 2013 From: contact at rkade.fr (rkadeFR) Date: Thu May 30 04:59:13 2013 Subject: [odb-users] Working with Date / DateTime / Time column in database without boost Message-ID: <51A714DC.5000403@rkade.fr> After some research, I found only answers for the boost library concerning working with a DateTime column in a database. I found interesting to open a thread in order to discuss to work with a DateTime column without any library (only standard library C++11). What's the best way for working with a DateTime column? I assume it's not with string (even though it's working). From boris at codesynthesis.com Thu May 30 08:56:27 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 30 08:55:09 2013 Subject: [odb-users] Working with Date / DateTime / Time column in database without boost In-Reply-To: <51A714DC.5000403@rkade.fr> References: <51A714DC.5000403@rkade.fr> Message-ID: Hi, rkadeFR writes: > After some research, I found only answers for the boost library > concerning working with a DateTime column in a database. In addition to the Boost Date-Time library, you can also use the Qt date-time types. > I found interesting to open a thread in order to discuss to work > with a DateTime column without any library (only standard library > C++11). You need some C++ type that represents the date-time values and there is nothing like this yet in standard C++. Well, C++11 added the chrono library but all it adds, as far as I can see, is the std::time_t and std::tm aliases for the corresponding C structs. These types are very basic and using them directly would be quite painful. That's why most people prefer to use something like the Boost Date-Time library. But I suppose we could add mapping for std::time_t and std::tm if people would find it useful. At the same time, if you have your own date-time type, then it is fairly easy to map it to the corresponding database date- time type. For more information on how to do this, see this detailed guide (the "Simple Value Types" section): http://www.codesynthesis.com/~boris/blog/2012/10/16/custom-cxx-to-database-type-mapping-in-odb/ Boris From tenchu.tarik at hotmail.fr Thu May 30 11:16:58 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Thu May 30 11:17:06 2013 Subject: [odb-users] Catch Exception Problem Message-ID: Hello, I am trying to persist a new object in the DB, but I have an constraint integrity exception. The problem is that this exception is not caught by my code. I am doing something wrong but I don't know what. My code is : template bool CreateNewObject(Type * object) { if(object != NULL) { transaction * transact = NULL; try { std::unique_ptr db (create_database()); transact = new transaction (db->begin()); // Make object persistent. db->persist((*object)); transact->commit(); } catch (const odb::exception& e) { cerr << e.what () << endl; if(transact != NULL) { transact->rollback(); } } } return false; } Can someone help me please? Best, Tarik From boris at codesynthesis.com Thu May 30 12:03:52 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 30 12:02:35 2013 Subject: [odb-users] Catch Exception Problem In-Reply-To: References: Message-ID: Hi Tarik, Tarik BENZ writes: > The problem is that this exception is not caught by my code. All ODB exceptions derive from the odb::exception base, so if you catch that (as you do in your code), then you should be catching any ODB exception. > template bool CreateNewObject(Type * object) > { > if(object != NULL) > { > transaction * transact = NULL; > try > { > std::unique_ptr db (create_database()); > transact = new transaction (db->begin()); > > // Make object persistent. > db->persist((*object)); > transact->commit(); > } > catch (const odb::exception& e) > { > cerr << e.what () << endl; > if(transact != NULL) > { > transact->rollback(); > } > } > } > return false; > } What can happen here is that the call to rollback() inside your exception handler can throw. This is actually a good example of how not to do it. Don't allocate the transaction object with new -- just allocate it on the stack. If it is destroyed before commit() has been called (e.g., because an exception is thrown before you got a chance to call commit()), then it will automatically roll the transaction back. Also after certain failures (e.g., a connection is lost) it is pointless to try to call rollback. ODB is smart enough to handle that while your home-made auto-rollback is not. So, if I had to reimplement your code, it would look like this: template bool CreateNewObject(Type * object) { if(object != NULL) { try { std::unique_ptr db(create_database()); transaction t (db->begin()); // Make object persistent. db->persist(*object); t.commit(); return true; } catch (const odb::exception& e) { cerr << e.what () << endl; } } return false; } Just realized another problem in your code: the database instance will no longer exist in the exception handler where you try to rollback the transaction started on this database. And the exception that you are unable to catch is most likely access violations. Boris From tenchu.tarik at hotmail.fr Thu May 30 12:15:52 2013 From: tenchu.tarik at hotmail.fr (Tarik BENZ) Date: Thu May 30 12:15:59 2013 Subject: [odb-users] Catch Exception Problem In-Reply-To: References: , Message-ID: Thank you very much, now the exception is caught. Best Tarik > Date: Thu, 30 May 2013 12:03:52 -0400 > From: boris@codesynthesis.com > To: tenchu.tarik@hotmail.fr > CC: odb-users@codesynthesis.com > Subject: Re: [odb-users] Catch Exception Problem > > Hi Tarik, > > Tarik BENZ writes: > > > The problem is that this exception is not caught by my code. > > All ODB exceptions derive from the odb::exception base, so if you > catch that (as you do in your code), then you should be catching > any ODB exception. > > > > template bool CreateNewObject(Type * object) > > { > > if(object != NULL) > > { > > transaction * transact = NULL; > > try > > { > > std::unique_ptr db (create_database()); > > transact = new transaction (db->begin()); > > > > // Make object persistent. > > db->persist((*object)); > > transact->commit(); > > } > > catch (const odb::exception& e) > > { > > cerr << e.what () << endl; > > if(transact != NULL) > > { > > transact->rollback(); > > } > > } > > } > > return false; > > } > > What can happen here is that the call to rollback() inside your > exception handler can throw. This is actually a good example of > how not to do it. Don't allocate the transaction object with new -- > just allocate it on the stack. If it is destroyed before commit() > has been called (e.g., because an exception is thrown before you > got a chance to call commit()), then it will automatically roll > the transaction back. Also after certain failures (e.g., a connection > is lost) it is pointless to try to call rollback. ODB is smart > enough to handle that while your home-made auto-rollback is not. > > So, if I had to reimplement your code, it would look like this: > > template bool CreateNewObject(Type * object) > { > if(object != NULL) > { > try > { > std::unique_ptr db(create_database()); > transaction t (db->begin()); > > // Make object persistent. > db->persist(*object); > t.commit(); > > return true; > } > catch (const odb::exception& e) > { > cerr << e.what () << endl; > } > } > return false; > } > > Just realized another problem in your code: the database instance > will no longer exist in the exception handler where you try to > rollback the transaction started on this database. And the exception > that you are unable to catch is most likely access violations. > > Boris From an9bit at gmail.com Fri May 31 08:58:17 2013 From: an9bit at gmail.com (Andrey Devyatka) Date: Fri May 31 08:58:24 2013 Subject: [odb-users] Create schema error (unknown database schema '') Message-ID: Hi, Please tell me, can I use the static library in the following case: library.hpp: #ifndef _CPP_ODB_STATIC_LIBRARY_CPP_ #define _CPP_ODB_STATIC_LIBRARY_CPP_ #include odb::database* createDb(void); #pragma db object struct Test { #pragma db id auto int m_id; }; #endif // _CPP_ODB_STATIC_LIBRARY_CPP_ library.cpp: #include #include #include #include "library.hpp" odb::database* createDb(void) { odb::database* db = new odb::sqlite::database("test.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); odb::transaction t(db->begin()); odb::schema_catalog::create_schema(*db); t.commit(); return db; } main.cpp: include #include #include "library.hpp" int main() { try { odb::database* db = createDb(); std::cout << "SUCCESS" << std::endl; }catch(const odb::exception& ex){ std::cout << "ERROR: " << ex.what() << std::endl; } } build: $ odb --database sqlite --generate-schema library.hpp $ g++ -c library-odb.cxx library.cpp main.cpp $ ar cr library.a library.o library-odb.o $ g++ -o test1 library.o library-odb.o main.o -lodb-sqlite -lodb $ g++ -o test2 main.o library.a -lodb-sqlite -lodb test: $ ./test1 SUCCESS $ ./test2 ERROR: unknown database schema '' misc: $ uname -srm Linux 3.8.0-23-generic x86_64 $ g++ --version | head -n1 g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 $ odb --version | head -n1 ODB object-relational mapping (ORM) compiler for C++ 2.2.0 Thanks! -- Regards, Andrey From boris at codesynthesis.com Fri May 31 11:13:02 2013 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 31 11:11:56 2013 Subject: [odb-users] Create schema error (unknown database schema '') In-Reply-To: References: Message-ID: Hi Andrey, Andrey Devyatka writes: > Please tell me, can I use the static library in the following case: > > [...] This is exactly the same issue that we've discussed just a few days ago: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html Because your application doesn't directly reference any symbols from library-odb.cxx, the linker ignores library-odb.o from library.a. As a result the schema creation code does not end up in the executable. Normally this is not a problem since most application executables will also include code that persists objects, etc., which will force the linker to include all the object files from the library. In your test, however, all you do is create the schema. As mentioned in the above email, with GNU ld you can use the --whole-archive option to force the linker to include every object file from your static library: > $ g++ -o test2 main.o library.a -lodb-sqlite -lodb g++ -o test2 main.o -Wl,-whole-archive library.a -Wl,-no-whole-archive -lodb-sqlite -lodb Another thing that you may find useful is the 'separate' value for the --schema-format option. It will trigger the generation of the schema creation code as a separate C++ source file (library-schema.cxx). You can then perhaps link it directly to your executable instead of packaging it into a static library. See the ODB compiler command line documentation (man pages) for more information on this option. Boris From an9bit at gmail.com Fri May 31 12:57:02 2013 From: an9bit at gmail.com (Andrey Devyatka) Date: Fri May 31 12:57:09 2013 Subject: [odb-users] Create schema error (unknown database schema '') In-Reply-To: References: Message-ID: Thank you! 2013/5/31 Boris Kolpackov > Hi Andrey, > > Andrey Devyatka writes: > > > Please tell me, can I use the static library in the following case: > > > > [...] > > This is exactly the same issue that we've discussed just a few days > ago: > > http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html > > Because your application doesn't directly reference any symbols from > library-odb.cxx, the linker ignores library-odb.o from library.a. As > a result the schema creation code does not end up in the executable. > > Normally this is not a problem since most application executables > will also include code that persists objects, etc., which will > force the linker to include all the object files from the library. > > In your test, however, all you do is create the schema. As mentioned > in the above email, with GNU ld you can use the --whole-archive > option to force the linker to include every object file from your > static library: > > > > $ g++ -o test2 main.o library.a -lodb-sqlite -lodb > > g++ -o test2 main.o -Wl,-whole-archive library.a -Wl,-no-whole-archive > -lodb-sqlite -lodb > > Another thing that you may find useful is the 'separate' value for > the --schema-format option. It will trigger the generation of the > schema creation code as a separate C++ source file (library-schema.cxx). > You can then perhaps link it directly to your executable instead of > packaging it into a static library. See the ODB compiler command line > documentation (man pages) for more information on this option. > > Boris > -- ? ?????????, ?. ?. ???????. From adrian at adi-ware.ch Thu May 30 19:33:07 2013 From: adrian at adi-ware.ch (Adrian Imboden) Date: Sun Jun 2 10:54:24 2013 Subject: [odb-users] Building on Debian (testing/jessie) Message-ID: <51A7E1B3.9020705@adi-ware.ch> Hello there I found out about odb because of the very interesting C++Now presentation. Today, I wanted to build the odb suite myself (because there only exists a dpkg package for the odb compiler and not for the boost extension and the database backends). When I want to build odb compiler, I get this output: # ./bootstrap libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'. libtoolize: copying file `m4/libtool.m4' libtoolize: copying file `m4/ltoptions.m4' libtoolize: copying file `m4/ltsugar.m4' libtoolize: copying file `m4/ltversion.m4' libtoolize: copying file `m4/lt~obsolete.m4' configure.ac:12: error: possibly undefined macro: m4_equote If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. configure.ac:12: error: possibly undefined macro: m4_ifdef configure.ac:12: error: possibly undefined macro: AM_PROG_AR configure.ac:141: error: possibly undefined macro: AC_MSG_ERROR autoreconf: /usr/bin/autoconf failed with exit status: 1 Is building on Debian supported or not? If not, I would be willing to invest time into make it build there. I don't have much experience (yet?) with automake build systems tough. I just upgraded my system from wheezy to Jessie because I suspected that the required automake version is higher than my installed one (Google suggested that to me). If this is the case, even the testing release of Debian has a version that is too old... Thank you very much. Greetings Adi