From boris at codesynthesis.com Tue May 3 05:19:43 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 3 05:01:13 2011 Subject: [odb-users] See you at BoostCon 2011 Message-ID: Hi, Just a quick note to let you know I am giving two talks at this year's BoostCon[1] conference. The first is titled "Parsing C++ with GCC plugins". It is about the new GCC plugin architecture and how it can be used for parsing C++. The second talk is titled "Object-Relational Mapping with ODB and Boost". It covers the ODB[2] object-relational mapping (ORM) system for C++ and its integration with Boost. If any of you are attending the conference, please say Hi! [1] http://boostcon.boost.org/ [2] http://www.codesynthesis.com/products/odb/ Boris From jyriot at free.fr Tue May 3 14:03:48 2011 From: jyriot at free.fr (Jean-Yves Riot) Date: Tue May 3 14:15:04 2011 Subject: [odb-users] ODB 1.4.0 released Message-ID: <00E7FF0D8F5046E4BE724F6FCF672212@Lisa> Dear sir, I am trying to use your ODB components under Windows 7 with VStudio 2010 and use MySQL database. I have a problem ton compile the samples, there is a problem with libodb-mysql-1.4.0. 2 header files are missing mysql_time.h and mysql_version.h Is it normal or maybe I missed something? Best Regards, Jean-Yves Riot. From boris at codesynthesis.com Tue May 3 14:43:36 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 3 14:32:46 2011 Subject: [odb-users] ODB 1.4.0 released In-Reply-To: <00E7FF0D8F5046E4BE724F6FCF672212@Lisa> References: <00E7FF0D8F5046E4BE724F6FCF672212@Lisa> Message-ID: Hi Jean-Yves, Jean-Yves Riot writes: > I am trying to use your ODB components under Windows 7 with VStudio 2010 and > use MySQL database. > > [...] > > 2 header files are missing mysql_time.h and mysql_version.h These are MySQL headers that come with the MySQL installation. If you go to: http://dev.mysql.com/downloads/mysql And download, for example, mysql-5.5.11-win32.zip, these header files will be in the include\ directory inside the archive. To set Visual Studio to automatically locate MySQL header and library files you will need to add the include\ directory to the Include search list in the VC++ Directories dialog as well as the lib/opt/ directory to the Library search list. Boris From art at it-gen.net Thu May 12 09:29:46 2011 From: art at it-gen.net (=?KOI8-R?B?99HexdPMwdcg89DJ0snEz87P1w==?=) Date: Thu May 12 10:03:14 2011 Subject: [odb-users] ODB Help. Message-ID: Hello. I need some help in ODB! Can I set ReadOnly fields in objects? Also I need opportunity to talk to the field from the database at the rest of the other fields, but when we record the objects in database, this value should not sign. If no such opportunity, whether it planned to enter and when? Thanx Viacheslav. From boris at codesynthesis.com Thu May 12 20:40:48 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 12 18:24:38 2011 Subject: [odb-users] ODB Help. In-Reply-To: References: Message-ID: Hi Viacheslav, art@it-gen.net writes: > Can I set ReadOnly fields in objects? No, there is no such concept. I am also not sure this is something that ODB should handle. If the member is not modified, then it will not be changed in the database. It seems to me that all you need to do is make sure that the read-only member cannot be modified by the application. You may also be interested in the 'db transient' ODB pragma. > Also I need opportunity to talk to the field from the database at the rest > of the other fields, but when we record the objects in database, this > value should not sign. I don't understand this question. Can show some concrete example that illustrates what you are trying to achieve. Boris From boris at codesynthesis.com Mon May 16 10:22:00 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 16 23:22:16 2011 Subject: [odb-users] ODB Help. In-Reply-To: References: Message-ID: Hi, 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 art@it-gen.net writes: > So we have an external rating system that counts every day rating, and > it does not matter to us as operations rating renewed in ODB, but > important to the previous value rating which now sits in a cache > program, not erased numbered rating that sits in the database. > > Thats why we shared an one ODB object in two objects, and imitate > readonly follows - 2nd object only read from the database and do not > write in database. Ok, if I understand you correctly, you can emulate this behavior by adding a transient "cache" member (which is not stored in the databse) to your persistent class. For example: #pragma db object class post { public: post (unsigned int initial_rating) : rating_ (initial_rating), initial_rating_ (initial_rating) { } unsigned int initial_rating () const { return initial_rating_; } private: unsigned int rating_; #pragma db transient unsigned int initial_rating_; }; Would this work for you? Boris From uwe.kindler at cetoni.de Tue May 17 05:44:01 2011 From: uwe.kindler at cetoni.de (cetoni GmbH - Uwe Kindler) Date: Tue May 17 13:35:45 2011 Subject: [odb-users] ODB 1.4.0 and multiple profiles Message-ID: <4DD24361.4020000@cetoni.de> Hi, I have a question regarding ODB profiles. We work with Qt so we would need the ODB Qt profile. We also use some boost libraries so we would need the QDB boost profile too. Because we prefer boost::shared_ptr to QSharedPointer we would like to have boost::shared_ptr as default pointer type for persistent objects. Is it possible to do this with ODB - using profile boost and qt at the same time and making boost::shared_ptr the default pointer type? Thanks and regards, Uwe Kindler Dipl. Inf. (FH) Software Engineering cetoni GmbH Automatisierung und Mikrosysteme Am Wiesenring 6 D-07554 Korbussen Phone: +49 (0) 36602 338 28 Fax: +49 (0) 36602 338 11 Email: uwe.kindler@cetoni.de Web: http://www.cetoni.de Handelsregister Jena HRB 202566 Ust.-Ident-Nr. DE 1505 26212 Gesch?ftsf?hrer: Tilo Kunze From boris at codesynthesis.com Wed May 18 02:51:12 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 18 00:34:57 2011 Subject: [odb-users] ODB 1.4.0 and multiple profiles In-Reply-To: <4DD24361.4020000@cetoni.de> References: <4DD24361.4020000@cetoni.de> Message-ID: Uwe, cetoni GmbH - Uwe Kindler writes: > I have a question regarding ODB profiles. We work with Qt so we would > need the ODB Qt profile. We also use some boost libraries so we would > need the QDB boost profile too. Because we prefer boost::shared_ptr to > QSharedPointer we would like to have boost::shared_ptr as default > pointer type for persistent objects. Is it possible to do this with ODB > - using profile boost and qt at the same time and making > boost::shared_ptr the default pointer type? Nothing prevents you from using two profiles at the same time. The easiest way to get boost::shared_ptr as the default pointer is to make sure the -p (or --profile) ODB compiler option for Boost comes after Qt, for example: odb -d mysql -p qt -p boost file.hxx Alternatively, you can override the default pointer type with the --default-pointer option explicitly: odb -d mysql -p boost -p qt --default-pointer boost::shared_ptr file.hxx Note that --default-pointer must come after all th -p options. Boris From michal.demin at gmail.com Wed May 18 17:24:44 2011 From: michal.demin at gmail.com (Michal Demin) Date: Wed May 18 18:08:09 2011 Subject: [odb-users] Fix with-libodb configure option Message-ID: Hello Attached is patch for m4 script that fixes --with-libodb= configure option. Currently when with-libodb is used, it will try to link library from non-existing directory. One would assume that using $prefix from libodb as the with-libodb parameter would be enough. This is valid at least for libodb-mysql and libodb-boost. I guess that the same libodb.m4 script is used in other runtime/profile libraries and examples. This is useful when someone doesn't want system-wide installation of odb. Michal Demin -------------- next part -------------- A non-text attachment was scrubbed... Name: fix_with_libodb_m4.patch Type: text/x-patch Size: 437 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20110518/90f8c52e/fix_with_libodb_m4.bin From uwe.kindler at cetoni.de Thu May 19 03:29:01 2011 From: uwe.kindler at cetoni.de (cetoni GmbH - Uwe Kindler) Date: Thu May 19 08:37:46 2011 Subject: [odb-users] Problems using --output-dir option Message-ID: <4DD4C6BD.9080808@cetoni.de> Hi, We would like to place the ODB generated files into another directory to avoid mixing of generated files with our own source files. We have the following source tree: src qtlabb items Cavity.h Cavity.cpp WellPlate.h WellPlate.cpp vision optics ... The include path points to src directory. That means, to include a header we write: #include We would like to make the classes WellPlate and Cavity persistent and place the generated files into the items/odb directory: src qtlabb items odb Cavity-odb.h WellPlate-odb.h ... Cavity.h Cavity.cpp WellPlate.h WellPlate.cpp vision optics ... But the ODB compiler generates the following includes in WellPlate-odb.h: #include "WellPlate.h" #include With the --include-prefix option I can change the wrong path to "WellPlate.h" if I use the prefix .. But then the Cavity-odb.h path is still wrong and I have no glue how to change this. The only way I get it working is if I do not use --output-dir option and to let ODB store the generated files in the same directory like my source files. Is there any solution for this issue or do I something wrong here. Thank you From boris at codesynthesis.com Thu May 19 11:50:44 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 19 09:34:28 2011 Subject: [odb-users] Fix with-libodb configure option In-Reply-To: References: Message-ID: Hi Michal, Michal Demin writes: > Attached is patch for m4 script that fixes --with-libodb= configure option. > > Currently when with-libodb is used, it will try to link library from > non-existing directory. One would assume that using $prefix from libodb > as the with-libodb parameter would be enough. > > This is useful when someone doesn't want system-wide installation of odb. The original intent of the --with-libodb option (and other --with-xxx options in ODB in general), is to allow you to use the non-installed build directory of a library. While I suppose we could check both (first as a build directory, then as an install directory), the problem is that the default include/library directories could be changed, for example, with something like this: --lib-prefix .../lib64 The way we thought that the non-default installed directories would be handled is with the CPPFLAGS/LDFLAGS configure variables: ./configure CPPFLAGS=-I.../include LDFLAGS=-L../lib64 This is a bit more verbose but also more robust. So I tend to think that we should not apply this patch. What do you think? Boris From boris at codesynthesis.com Thu May 19 12:06:41 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 19 09:50:25 2011 Subject: [odb-users] Problems using --output-dir option In-Reply-To: <4DD4C6BD.9080808@cetoni.de> References: <4DD4C6BD.9080808@cetoni.de> Message-ID: Hi Uwe, cetoni GmbH - Uwe Kindler writes: > But the ODB compiler generates the following includes in WellPlate-odb.h: > > #include "WellPlate.h" > #include The ODB compiler comes up with the path based on the Cavity.h include in WellPlate.h (which I assume is ). I don't think ODB can figure out on its own that the include should instead be . This will be just too smart to be robust. What we have in our other product (XSD) to allow such include structures is the --include-regex option which allows you to transform all the include directives as you see fit. I think something like this will work well in your case. > With the --include-prefix option I can change the wrong path to > "WellPlate.h" if I use the prefix. You can also use the --include-with-brackets option to change the quote-include ("") to bracket-include (<>). The --guard-prefix option can also be useful. > The only way I get it working is if I do not use --output-dir option and > to let ODB store the generated files in the same directory like my > source files. Yes, this seems to be the only solution at the moment. We can try to implement the --include-regex option for the next release if you think it will work for you. Boris From boris at codesynthesis.com Fri May 20 11:07:08 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 20 08:50:51 2011 Subject: [odb-users] ODB on MinGW In-Reply-To: <4DD4C029.8090508@cetoni.de> References: <4DAEDBC3.7090404@cetoni.de> <4DD4C029.8090508@cetoni.de> Message-ID: Hi Uwe, [I'am CC'ing the odb-users mailing list to this portion of my reply in case others have a similar question.] cetoni GmbH - Uwe Kindler writes: > Compiling the ODB libraries with MinGW was not that easy but I managed > to get working libraries. We use ODB with Sqlite. MinGW prints some > warnings because of auto imported symbols. Normally if you compile > windows DLLs you need to export symbols via _declspec(dllexport) like > you do it via LIBODB_EXPORT macro. But for MinGW builds it is easier to > rely on the -enable-auto-import and -export-all-symbols features. That > means for MinGW builds these two options should get added to the > compiler/linker options. Actually we test every release of ODB with MinGW and all ODB libraries are MinGW-aware and properly export the necessary symbols, just like when built with VC++. The advantage of this approach compared to using --export-all-symbols is that the libraries are smaller. We still use the --enable-auto-import in order to get rid of warnings when linking to libstdc++ which doesn't export the symbols explicitly. So the configure command like that we use for building on MinGW is this: ./configure LDFLAGS="-Wl,--enable-auto-import" And as far as I know the build is warning-free. Boris From boris at codesynthesis.com Sun May 22 16:22:30 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun May 22 14:06:09 2011 Subject: [odb-users] ODB Help. In-Reply-To: References: Message-ID: Hi, Please keep your replies CC'ed to the odb-users mailing list. This is the second (and last) time I am asking you to do this. See the posting guidelines for details: http://www.codesynthesis.com/support/posting-guidelines.xhtml art@it-gen.net writes: > We don't need to change our code in this field, and we will never > change it, we're just using it for information purposes in the form in > which it is in a database. The problem is that this field is changing > in uncertain intervals of time an outside software. That is a big > chance that after we downloaded the object from a database using odb:: > load () and worked with him for some time, but did not not yet have > written back the object in a database with odb:: update () an outside > software changed the value rating_ on a new field. In our code yet > saved the old value and if make odb:: update (), our old value is > overwrite the new value that is in the database. Ok, I think I understand your use case better now. Looks like we will need a readonly pragma to support this. I will try to add it for the next release of ODB. Boris From art at it-gen.net Mon May 23 09:39:08 2011 From: art at it-gen.net (=?KOI8-R?B?99HexdPMwdcg89DJ0snEz87P1w==?=) Date: Mon May 23 09:39:16 2011 Subject: [odb-users] ODB Help with qualifier ID and object id Message-ID: Hi,?Boris Kolpackov. Thank you for help and we will wait?next release of ODB. Also we have one more question. Please give an example the recommended behaviour for a situation when there is no necessity for a separate field which contains value object id. As qualifier id is obligatory it is necessary to enter redundancy into structure of tables for which the concept object id basically is not necessary. Thanks for your answer. 2011/5/22 Boris Kolpackov : > Hi, > > Please keep your replies CC'ed to the odb-users mailing list. This > is the second (and last) time I am asking you to do this. See the > posting guidelines for details: > > http://www.codesynthesis.com/support/posting-guidelines.xhtml > > art@it-gen.net writes: > >> We don't need to change our code in this field, and we will never >> change it, we're just using it for information purposes in the form in >> which it is in a database. The problem is that this field is changing >> in uncertain intervals of time an outside software. That is a big >> chance that after we downloaded the object from a database using odb:: >> load () and worked with him for some time, but did not not yet have >> written back the object in a database with odb:: update () an outside >> software changed the value rating_ ?on a new field. In our code yet >> saved the old value and if make odb:: update (), our old value is >> overwrite the new value that is in the database. > > Ok, I think I understand your use case better now. Looks like we will > need a readonly pragma to support this. I will try to add it for the > next release of ODB. > > Boris > From boris at codesynthesis.com Mon May 23 16:42:35 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 23 14:26:19 2011 Subject: [odb-users] ODB Help with qualifier ID and object id In-Reply-To: References: Message-ID: Hi, art@it-gen.net writes: > Please give an example the recommended behaviour for a situation when > there is no necessity for a separate field which contains value object > id. As qualifier id is obligatory it is necessary to enter redundancy > into structure of tables for which the concept object id basically is > not necessary. There are two possible ways we can support this. The first is to have an implicit id, for example unsigned long long with auto-assignment semantics. In this case, while the object does not have the id member, the table still has the id column (which is also a primary key). The second approach is not to have the id column either. In other words, the resulting table will not have a primary key. This is legal from the database standpoint but somewhat unusual from the the design perspective. Which of the above two scenarios do you have? Boris From art at it-gen.net Wed May 25 05:28:26 2011 From: art at it-gen.net (=?KOI8-R?B?99HexdPMwdcg89DJ0snEz87P1w==?=) Date: Wed May 25 05:28:33 2011 Subject: [odb-users] RE ODB Help with qualifier ID and object id Message-ID: We use the second approach. For example ?++ code logged the certain data. That is our code only insert the data in the table. How the data from the table is read does not interest at all us. Here table structure: CREATE TABLE IF NOT EXISTS `log` ( `DateC` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `UserId` int(10) unsigned NOT NULL, `Type` tinyint(3) unsigned NOT NULL, `Value` int(11) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; As a matter of fact it is possible to consider primary key a set of DateC, UserId and Type, but such approach has the big redundancy (overhead). It considerably reduces efficiency of an insertion of the data in the table. Let's note that it is the main our operation and we want that it was as much as possible effective. Other variant is introduction of an additional fictitious field - `Id` bigint(20) unsigned NOT NULL AUTO_INCREMENT. But this is also overhead. In the present situation can be the effective decision for indirect usage may be 2 independent indexes: DateC - for samples for a certain interval of time UserId - for samples on the specific User But ?++ code at all does not concern, its task simply to fill the table with the data. Thank for answer. ----------------------------- > Please give an example the recommended behaviour for a situation when > there is no necessity for a separate field which contains value object > id. As qualifier id is obligatory it is necessary to enter redundancy > into structure of tables for which the concept object id basically is > not necessary. -------------------------- There are two possible ways we can support this. The first is to have an implicit id, for example unsigned long long with auto-assignment semantics. In this case, while the object does not have the id member, the table still has the id column (which is also a primary key). The second approach is not to have the id column either. In other words, the resulting table will not have a primary key. This is legal from the database standpoint but somewhat unusual from the the design perspective. Which of the above two scenarios do you have? -------------------------------------------- From boris at codesynthesis.com Wed May 25 13:59:16 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 25 11:42:58 2011 Subject: [odb-users] RE ODB Help with qualifier ID and object id In-Reply-To: References: Message-ID: Hi, writes: > We use the second approach. Ok, thanks for the explanation. I have added this to our TODO list. I am not sure we will be able to implement this for the next release but we will try. > CREATE TABLE IF NOT EXISTS `log` ( > `DateC` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, > `UserId` int(10) unsigned NOT NULL, > `Type` tinyint(3) unsigned NOT NULL, > `Value` int(11) NOT NULL, > PRIMARY KEY (`Id`) > ) ENGINE=MyISAM DEFAULT CHARSET=utf8; What about the "PRIMARY KEY (`Id`)" part in the above table? It this a typo? Boris