From buptstehc at gmail.com Thu Jan 2 09:18:08 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Thu Jan 2 09:18:46 2014 Subject: [odb-users] boost::exception Message-ID: Hi,All! I have a client to do insert operation frequently. when i cut off the connection between the client and db, my program throws 'boost::exception_detail::clone_impl >' which i can't catch. this is my code: odb::transaction t (db_->begin()); //1 db_->persist(m); //2 t.commit(); //3 and the exception throws at line 1. i have tried catch 'boost::system:: system_error', but fails. please help! From boris at codesynthesis.com Thu Jan 2 09:27:18 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 2 09:29:41 2014 Subject: [odb-users] boost::exception In-Reply-To: References: Message-ID: Hi, buptstehc@gmail.com writes: > odb::transaction t (db_->begin()); //1 > db_->persist(m); //2 > t.commit(); //3 > > and the exception throws at line 1. i have tried catch 'boost::system:: > system_error', but fails. It cannot be a Boost exception since none of the above code uses Boost. Try catching odb::exception. Boris From lidia at lemur-soft.com Thu Jan 2 09:42:04 2014 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Thu Jan 2 09:42:12 2014 Subject: [odb-users] db scheme and data migration scheme Message-ID: Hello, Is it possible to have automatic db scheme and data migration to both directions - from old to new and new to old versions ? Scenario why we need it: We have one server that sends database with newest version. We have clients with different software ( and therefore db ) versions. Server should be able to convert newest version to some old one. As well, client would be able to migrate db to newest one in case new software has been installed. ( to implement this I thought use info from .xml generated by odb compiler and make reverse changes myself. But if there is another better option, I would appreciate any advice ). Thanks in advance. Lidia. -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Fri Jan 3 03:26:15 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 3 03:28:40 2014 Subject: [odb-users] db scheme and data migration scheme In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > Is it possible to have automatic db scheme and data migration to both > directions - from old to new and new to old versions? No, ODB does not support this. Also, generally speaking, database schema evolution is fairly complex already so if you can, I would suggest that you try to keep it as simple as possible. Trying to support migrations in both directions is sure to complicate your life significantly. > We have one server that sends database with newest version. We have clients > with different software ( and therefore db ) versions. Server should be > able to convert newest version to some old one. As well, client would be > able to migrate db to newest one in case new software has been installed. One mechanism that may help you implement this is the soft model changes. The general idea is outlined in this paragraph from the manual: "The most complex approach is working with multiple versions of the database without performing any migrations, schema or data. ODB does provide support for implementing this approach (Section 13.4, "Soft Object Model Changes"), however we will not cover it any further in this chapter. Generally, this will require embedding knowledge about each version into the core application logic which makes it hard to maintain for any non-trivial object model." In your case, both your server and client will not perform any migrations but rather be capable of working with any version of the database (or some range of versions). You won't be able to send a new database to an old client, though. > ( to implement this I thought use info from .xml generated by odb compiler > and make reverse changes myself. But if there is another better option, I > would appreciate any advice ). Yes, theoretically, you could read the changelog and try to produce a set of SQL files that do the reverse. Unless you only use a limited number of changes (e.g., only adding/removing columns), then this will involve some work. Also keep in mind that SQLite (which is what I believe you are using) has a very limited support for DDL. In particular it is not possible to drop columns in SQLite. Boris From buptstehc at gmail.com Sat Jan 4 02:47:21 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Sat Jan 4 02:47:58 2014 Subject: [odb-users] boost::exception In-Reply-To: References: Message-ID: Thanks, Boris. I have found the problem and it is not related to odb. I have another question about odb. since i am using oracle, when i follow the example, define the header file, generate code using odb compiler command 'odb -d oracle --profile boost/date-time --generate-schema message.hxx', the generated sql file add table name and field name with double quote like this: CREATE TABLE "JupiterMessage" ( "id" NUMBER(20) NOT NULL PRIMARY KEY, "name" VARCHAR2(512) NULL, "content" CLOB NOT NULL, "local" VARCHAR2(512) NULL, "remote" VARCHAR2(512) NULL, "create_time" VARCHAR2(512) NULL, "processed" NUMBER(1) DEFAULT 0 NOT NULL); how can i remove ? thanks! 2014/1/2 Boris Kolpackov > Hi, > > buptstehc@gmail.com writes: > > > odb::transaction t (db_->begin()); //1 > > db_->persist(m); //2 > > t.commit(); //3 > > > > and the exception throws at line 1. i have tried catch 'boost::system:: > > system_error', but fails. > > It cannot be a Boost exception since none of the above code uses Boost. > Try catching odb::exception. > > Boris > From lidia at lemur-soft.com Sat Jan 4 10:19:56 2014 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Sat Jan 4 10:20:04 2014 Subject: [odb-users] db scheme and data migration scheme In-Reply-To: References: Message-ID: Thanks a lot for informative and quick response. On Fri, Jan 3, 2014 at 10:26 AM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > Is it possible to have automatic db scheme and data migration to both > > directions - from old to new and new to old versions? > > No, ODB does not support this. Also, generally speaking, database > schema evolution is fairly complex already so if you can, I would > suggest that you try to keep it as simple as possible. Trying to > support migrations in both directions is sure to complicate your > life significantly. > > > > We have one server that sends database with newest version. We have > clients > > with different software ( and therefore db ) versions. Server should be > > able to convert newest version to some old one. As well, client would be > > able to migrate db to newest one in case new software has been installed. > > One mechanism that may help you implement this is the soft model changes. > The general idea is outlined in this paragraph from the manual: > > "The most complex approach is working with multiple versions of the > database > without performing any migrations, schema or data. ODB does provide > support > for implementing this approach (Section 13.4, "Soft Object Model > Changes"), > however we will not cover it any further in this chapter. Generally, this > will require embedding knowledge about each version into the core > application > logic which makes it hard to maintain for any non-trivial object model." > > In your case, both your server and client will not perform any migrations > but rather be capable of working with any version of the database (or > some range of versions). You won't be able to send a new database to > an old client, though. > > > > ( to implement this I thought use info from .xml generated by odb > compiler > > and make reverse changes myself. But if there is another better option, I > > would appreciate any advice ). > > Yes, theoretically, you could read the changelog and try to produce > a set of SQL files that do the reverse. Unless you only use a limited > number of changes (e.g., only adding/removing columns), then this will > involve some work. Also keep in mind that SQLite (which is what I believe > you are using) has a very limited support for DDL. In particular it is > not possible to drop columns in SQLite. > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Mon Jan 6 00:55:10 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 6 00:57:34 2014 Subject: [odb-users] Re: SQL identifier quoting in Oracle In-Reply-To: References: Message-ID: Hi, buptstehc@gmail.com writes: > I have another question about odb. In this case please start a new thread with a proper subject, as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml > [...] the generated sql file add table name and field name with > double quote like this: > > CREATE TABLE "JupiterMessage" ( > "id" NUMBER(20) NOT NULL PRIMARY KEY, > "name" VARCHAR2(512) NULL, > "content" CLOB NOT NULL, > "local" VARCHAR2(512) NULL, > "remote" VARCHAR2(512) NULL, > "create_time" VARCHAR2(512) NULL, > "processed" NUMBER(1) DEFAULT 0 NOT NULL); > > how can i remove ? You cannot. ODB always quotes all the SQL identifiers to avoid clashes with keywords, etc. You didn't say why you want quoting removed but I suspect it has something to do with Oracle's automatic upper-casing of unquoted identifiers. If that's the case, take a look at the --sql-name-case ODB compiler option as well as the SQL NAME TRANSFORMATIONS section in the ODB command line manual: http://www.codesynthesis.com/products/odb/doc/odb.xhtml Boris From 378549984 at qq.com Wed Jan 1 08:31:27 2014 From: 378549984 at qq.com (=?gb18030?B?Mzc4NTQ5OTg0?=) Date: Mon Jan 6 02:30:52 2014 Subject: [odb-users] ERROR 1044 (42000): Access denied for user ''@'localhost' to database Message-ID: Hello,I've installed all those libraries needed, and configured the odb-example-2.3.0 successfully on my Ubuntu12.04. But when I want to run next command"make check",it came out to be an ERROR: ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'odb_test' FAIL: ../tester When I searched this online,some articles said it's because the MySQL has an empty user "root" for the database,I did update the table "user" int the database "mysql" by commands: mysql>use mysql; ?? mysql>update user set password=password('newpwd') WHERE User='root'; mysql>flush privileges; But after all of this,this ERROR just still exists,so I send this mail and hope that someone could give me a reply. Thank you. From boris at codesynthesis.com Mon Jan 6 02:42:13 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 6 02:44:38 2014 Subject: [odb-users] ERROR 1044 (42000): Access denied for user ''@'localhost' to database In-Reply-To: References: Message-ID: Hi, 378549984 <378549984@qq.com> writes: > I've installed all those libraries needed, and configured the > odb-example-2.3.0 successfully on my Ubuntu12.04. But when I > want to run next command "make check",it came out to be an ERROR: > > ERROR 1044 (42000): Access denied for user ''@'localhost' to database > 'odb_test' When configuring the ODB examples you can use --with-mysql-* options (run configure --help to see the list of them) to specify the MySQL user, password, and database that the examples should use. Running examples as the root MySQL user is a really bad idea. Instead, I suggest that you use a different database user. Here is how you can create a separate user and database for ODB: Login to mysql as root and then run these SQL statements: CREATE USER odb_test@'%'; CREATE USER odb_test@'localhost'; CREATE DATABASE odb_test; GRANT ALL PRIVILEGES ON odb_test.* to odb_test@'%'; FLUSH PRIVILEGES; This will create a new user called odb_test and a new database also called odb_test. The odb_test user will have no password. Once this is done, configure the ODB examples like this: ./configure --with-database=mysql --with-mysql-user=odb_test \ --with-mysql-password=no --with-mysql-db=odb_test ... Also note that here we assume that you run the examples on the same machine as the the MySQL server itself. If that's not the case, then use the --with-mysql-host option to specify the remote MySQL host. Boris From 378549984 at qq.com Mon Jan 6 03:09:38 2014 From: 378549984 at qq.com (=?gb18030?B?Mzc4NTQ5OTg0?=) Date: Mon Jan 6 12:20:19 2014 Subject: [odb-users] ERROR 1044 (42000): Access denied for user''@'localhost' to database In-Reply-To: References: Message-ID: Thank you for your replying. And I fixed it by myself with the same method you mentioned.Thank you. ------------------ Original ------------------ From: "Boris Kolpackov"; Date: 2014?1?6?(???) ??3:42 To: ""<378549984@qq.com>; Cc: "odb-users"; Subject: Re: [odb-users] ERROR 1044 (42000): Access denied for user''@'localhost' to database Hi, 378549984 <378549984@qq.com> writes: > I've installed all those libraries needed, and configured the > odb-example-2.3.0 successfully on my Ubuntu12.04. But when I > want to run next command "make check",it came out to be an ERROR: > > ERROR 1044 (42000): Access denied for user ''@'localhost' to database > 'odb_test' When configuring the ODB examples you can use --with-mysql-* options (run configure --help to see the list of them) to specify the MySQL user, password, and database that the examples should use. Running examples as the root MySQL user is a really bad idea. Instead, I suggest that you use a different database user. Here is how you can create a separate user and database for ODB: Login to mysql as root and then run these SQL statements: CREATE USER odb_test@'%'; CREATE USER odb_test@'localhost'; CREATE DATABASE odb_test; GRANT ALL PRIVILEGES ON odb_test.* to odb_test@'%'; FLUSH PRIVILEGES; This will create a new user called odb_test and a new database also called odb_test. The odb_test user will have no password. Once this is done, configure the ODB examples like this: ./configure --with-database=mysql --with-mysql-user=odb_test \ --with-mysql-password=no --with-mysql-db=odb_test ... Also note that here we assume that you run the examples on the same machine as the the MySQL server itself. If that's not the case, then use the --with-mysql-host option to specify the remote MySQL host. Boris . From mail at adrianimboden.ch Mon Jan 6 12:08:22 2014 From: mail at adrianimboden.ch (Adrian Imboden) Date: Mon Jan 6 12:20:19 2014 Subject: [odb-users] ODB Query using relation Message-ID: <52CAE306.50901@adrianimboden.ch> Hi there I have a question about ODB queries. I saw many examples where the queries are very simple. Now I wanted to query a list of users depending on their token, which is a foreign key. The definitions (removed unused members for now): #pragma db object optimistic class User { public: #pragma db id auto uint32_t id = 0; std::string name; #pragma db column("emailToken") std::shared_ptr emailToken; odb::vector> authTokens #pragma db version size_t version = 0; }; #pragma db object optimistic class Token { public: #pragma db id auto uint32_t id = 0; std::string hash; boost::posix_time::ptime expirationTime; #pragma db version size_t version = 0; }; I want to do two different queries: 1. Find all users that have an emailToken that has a given hash 2. Find all users that have at least one authToken with a given hash Using SQL I would do a join. Is there something similar possible with queries or is this only possible using some views? Thank you and Greetings Adrian Imboden PS: nice project by the way -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3067 bytes Desc: S/MIME Cryptographic Signature Url : http://codesynthesis.com/pipermail/odb-users/attachments/20140106/9c8c3d8f/smime.bin From boris at codesynthesis.com Tue Jan 7 03:33:26 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 7 03:35:50 2014 Subject: [odb-users] ODB Query using relation In-Reply-To: <52CAE306.50901@adrianimboden.ch> References: <52CAE306.50901@adrianimboden.ch> Message-ID: Hi Adrian, Adrian Imboden writes: > #pragma db object optimistic > class User > { > public: > #pragma db id auto > uint32_t id = 0; > > std::string name; > > #pragma db column("emailToken") > std::shared_ptr emailToken; > > odb::vector> authTokens > > #pragma db version > size_t version = 0; > }; > > #pragma db object optimistic > class Token > { > public: > #pragma db id auto > uint32_t id = 0; > > std::string hash; > > boost::posix_time::ptime expirationTime; > > #pragma db version > size_t version = 0; > }; > > 1. Find all users that have an emailToken that has a given hash This one is easy since you can use pointed-to objects in queries (as discussed in the manual): typedef odb::query query; db->query (query::emailToken->hash == "1234"); > 2. Find all users that have at least one authToken with a given hash This one is a bit trickier since ODB does not yet support querying of containers. So here you will need to use a view: #pragma db view object(User) object(Token = AuthToken: User::authTokens) struct UserView { #pragma db column(User::id) uint32_t id; }; typedef odb::query query; db->query (query::AuthToken::hash == "1234"); This will give you a list of User object ids that match the condition. Given that, you can then load the actual objects. Alternatively, you can pull the data members you are interested in directly in the view. > PS: nice project by the way Thanks, I am glad you are enjoying it. Boris From mail at adrianimboden.ch Tue Jan 7 04:22:36 2014 From: mail at adrianimboden.ch (Adrian Imboden) Date: Tue Jan 7 04:37:44 2014 Subject: [odb-users] ODB Query using relation In-Reply-To: References: <52CAE306.50901@adrianimboden.ch> Message-ID: <52CBC75C.9030508@adrianimboden.ch> On 07.01.2014 09:33, Boris Kolpackov wrote: > Hi Adrian, > > Adrian Imboden writes: > >> #pragma db object optimistic >> class User >> { >> public: >> #pragma db id auto >> uint32_t id = 0; >> >> std::string name; >> >> #pragma db column("emailToken") >> std::shared_ptr emailToken; >> >> odb::vector> authTokens >> >> #pragma db version >> size_t version = 0; >> }; >> >> #pragma db object optimistic >> class Token >> { >> public: >> #pragma db id auto >> uint32_t id = 0; >> >> std::string hash; >> >> boost::posix_time::ptime expirationTime; >> >> #pragma db version >> size_t version = 0; >> }; >> >> 1. Find all users that have an emailToken that has a given hash > This one is easy since you can use pointed-to objects in queries > (as discussed in the manual): > > typedef odb::query query; > > db->query (query::emailToken->hash == "1234"); Ah great. I must have overlooked this part. > >> 2. Find all users that have at least one authToken with a given hash > This one is a bit trickier since ODB does not yet support querying > of containers. So here you will need to use a view: > > #pragma db view object(User) object(Token = AuthToken: User::authTokens) > struct UserView > { > #pragma db column(User::id) > uint32_t id; > }; > > typedef odb::query query; > > db->query (query::AuthToken::hash == "1234"); > > This will give you a list of User object ids that match the condition. > Given that, you can then load the actual objects. Alternatively, you > can pull the data members you are interested in directly in the view. Great, I will use a view then. Is there already some idea how to implement this feature? If there is need, I could invest some time too. > > >> PS: nice project by the way > Thanks, I am glad you are enjoying it. > > Boris > Adi From boris at codesynthesis.com Wed Jan 8 02:04:50 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 8 02:07:15 2014 Subject: [odb-users] ODB Query using relation In-Reply-To: <52CBC75C.9030508@adrianimboden.ch> References: <52CAE306.50901@adrianimboden.ch> <52CBC75C.9030508@adrianimboden.ch> Message-ID: Hi Adrian, Adrian Imboden writes: > > This one is a bit trickier since ODB does not yet support querying > > of containers. > > Is there already some idea how to implement this feature? If there is > need, I could invest some time too. The hard part is exactly that: figuring out what the proper semantics and the syntax to go with it are and how to implement them. When people are using a container in a query condition, we need to know which elements to consider. This can be some specific element (e.g., the first element), any element, all elements, a range of elements, etc. I think the "any element" will be the most widely used case and is the one we definitely have to support. Others, I am not sure it will even be possible to implement in SQL in any sane way (e.g., all elements, a range of elements). Maybe what we should do is expose the index column (or the key column for maps) to the user so that they can create whatever conditions they want. Something along these lines: query::authTokens.index == 0 && query::authTokens->hash == 123 [Note the problem with this syntax: a container element may also have a data member named index.] It is also not clear how to implement the "all elements" case with this approach, or in SQL in a sane/portable way in general. So, as you can see, there are a lot of questions that need thinking and answering ;-). If you (or anyone else) want to spend some time on that, we can try to flesh this feature out. Boris From mail at adrianimboden.ch Wed Jan 8 05:36:02 2014 From: mail at adrianimboden.ch (Adrian Imboden) Date: Wed Jan 8 06:36:36 2014 Subject: [odb-users] ODB Query using relation In-Reply-To: References: <52CAE306.50901@adrianimboden.ch> <52CBC75C.9030508@adrianimboden.ch> Message-ID: <52CD2A12.8030402@adrianimboden.ch> On 08.01.2014 08:04, Boris Kolpackov wrote: > Hi Adrian, > > Adrian Imboden writes: > >>> This one is a bit trickier since ODB does not yet support querying >>> of containers. >> Is there already some idea how to implement this feature? If there is >> need, I could invest some time too. > The hard part is exactly that: figuring out what the proper semantics > and the syntax to go with it are and how to implement them. > > When people are using a container in a query condition, we need to > know which elements to consider. This can be some specific element > (e.g., the first element), any element, all elements, a range of > elements, etc. > > I think the "any element" will be the most widely used case and is > the one we definitely have to support. Others, I am not sure it will > even be possible to implement in SQL in any sane way (e.g., all > elements, a range of elements). Maybe what we should do is expose > the index column (or the key column for maps) to the user so that > they can create whatever conditions they want. Something along > these lines: > > query::authTokens.index == 0 && query::authTokens->hash == 123 > > [Note the problem with this syntax: a container element may also > have a data member named index.] > > It is also not clear how to implement the "all elements" case > with this approach, or in SQL in a sane/portable way in general. > > So, as you can see, there are a lot of questions that need > thinking and answering ;-). If you (or anyone else) want to > spend some time on that, we can try to flesh this feature out. > > Boris > I will use the library a little bit more at first, to get a better feeling. I might come back to it later :) Adi From buptstehc at gmail.com Tue Jan 14 01:54:04 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Tue Jan 14 01:54:43 2014 Subject: [odb-users] memory leak Message-ID: Hi,all! when i test inserting data multiple times , the handles occupied by my program is increasing from process manager in windows, my code is as follows: odb::transaction t (db_->begin()); db_->persist(m); db_->execute(sql); t.commit(); since every time when i insert a new data, i will create a new transaction t, i want to know whether i can create this once and reuse over and over again?thanks! From buptstehc at gmail.com Tue Jan 14 02:22:12 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Tue Jan 14 02:22:52 2014 Subject: [odb-users] Re: memory leak In-Reply-To: References: Message-ID: sorry, the code should be this: odb::transaction t (db_->begin()); db_->execute(sql); t.commit(); 2014/1/14 ?? > Hi,all! when i test inserting data multiple times , the handles occupied > by my program is increasing from process manager in windows, my code is as > follows: > > odb::transaction t (db_->begin()); > db_->persist(m); > db_->execute(sql); > t.commit(); > > since every time when i insert a new data, i will create a new transaction t, > i want to know whether i can create this once and reuse over and over > again?thanks! > From buptstehc at gmail.com Tue Jan 14 03:15:41 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Tue Jan 14 03:16:20 2014 Subject: [odb-users] Re: memory leak In-Reply-To: References: Message-ID: i have tried by resusing the transaction instance like this: odb::transaction::current (*t_); db_->execute(sql); t_->commit(); t_->reset(db_->begin()); but the handles is still increasing. 2014/1/14 ?? > sorry, the code should be this: > odb::transaction t (db_->begin()); > db_->execute(sql); > t.commit(); > > > > > 2014/1/14 ?? > >> Hi,all! when i test inserting data multiple times , the handles occupied >> by my program is increasing from process manager in windows, my code is as >> follows: >> >> odb::transaction t (db_->begin()); >> db_->persist(m); >> db_->execute(sql); >> t.commit(); >> >> since every time when i insert a new data, i will create a new >> transaction t, i want to know whether i can create this once and reuse >> over and over again?thanks! >> > > From info at peredin.com Tue Jan 14 03:35:32 2014 From: info at peredin.com (Per Edin) Date: Tue Jan 14 03:35:39 2014 Subject: [odb-users] Re: memory leak In-Reply-To: References: Message-ID: Hi, A transaction will require resources, be that WinAPI handles or something else on other systems. I wouldn't care that much about it at first. Try not to optimize too early. Make it work first, and then, if you experience performance problems, try to optimize them away. :) Cheers, Per On Tue, Jan 14, 2014 at 9:15 AM, ?? wrote: > i have tried by resusing the transaction instance like this: > odb::transaction::current (*t_); > db_->execute(sql); > t_->commit(); > t_->reset(db_->begin()); > > but the handles is still increasing. > > > 2014/1/14 ?? > >> sorry, the code should be this: >> odb::transaction t (db_->begin()); >> db_->execute(sql); >> t.commit(); >> >> >> >> >> 2014/1/14 ?? >> >>> Hi,all! when i test inserting data multiple times , the handles occupied >>> by my program is increasing from process manager in windows, my code is as >>> follows: >>> >>> odb::transaction t (db_->begin()); >>> db_->persist(m); >>> db_->execute(sql); >>> t.commit(); >>> >>> since every time when i insert a new data, i will create a new >>> transaction t, i want to know whether i can create this once and reuse >>> over and over again?thanks! >>> >> >> From boris at codesynthesis.com Tue Jan 14 09:43:26 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 14 09:46:06 2014 Subject: [odb-users] memory leak In-Reply-To: References: Message-ID: Hi, ?? writes: > Hi,all! when i test inserting data multiple times , the handles occupied by > my program is increasing from process manager in windows If you have code like this: for (int i = 0; i < 1000000; ++i) { odb::transaction t (db_->begin()); db_->persist(m); db_->execute(sql); t.commit(); } Then all the resources allocated by ODB are released at the end of each iteration. There, however, could still be some resources that are allocated and cached by the underlying database library. In this case what you should see is an initial increase in resources which stops growing over time. Boris From buptstehc at gmail.com Tue Jan 14 09:59:07 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Tue Jan 14 09:59:44 2014 Subject: [odb-users] memory leak In-Reply-To: References: Message-ID: thanks Boris! Does "an initial increase in resources which stops growing over time." means the resources will be released at some time? can i release it manually? 2014/1/14 Boris Kolpackov > Hi, > > ?? writes: > > > Hi,all! when i test inserting data multiple times , the handles occupied > by > > my program is increasing from process manager in windows > > If you have code like this: > > for (int i = 0; i < 1000000; ++i) > { > odb::transaction t (db_->begin()); > db_->persist(m); > db_->execute(sql); > t.commit(); > } > > Then all the resources allocated by ODB are released at the end of each > iteration. There, however, could still be some resources that are > allocated and cached by the underlying database library. In this > case what you should see is an initial increase in resources which > stops growing over time. > > Boris > From boris at codesynthesis.com Tue Jan 14 11:51:22 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 14 11:53:46 2014 Subject: [odb-users] memory leak In-Reply-To: References: Message-ID: Hi, ?? writes: > Does "an initial increase in resources which stops growing > over time." means the resources will be released at some time? > can i release it manually? The only sure way to release all the cached resources is to destroy the odb::database instance (db_ in your case). Even then it is possible that the underlying database library (that is, the C API to the database) will still hold some resources. Boris From lidia at lemur-soft.com Wed Jan 15 07:33:48 2014 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Wed Jan 15 07:33:55 2014 Subject: [odb-users] migration compiler problem. Message-ID: Hello We use odb inside static library. There is problem in MS VS that static initialization of create_schema and migrate_schema function initialization ( for example, static const schema_catalog_create_entry create_schema_entry_ ( id_sqlite, "", &create_schema); ) is not called when xxx-schema.cxx file, created with --schema-format separate flag, is inside static library. It's ok when this file is linked directly to the executable. Could you advice please ? Thanks. Lidia. -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Wed Jan 15 07:40:09 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 15 07:42:33 2014 Subject: [odb-users] migration compiler problem. In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > We use odb inside static library. > > There is problem in MS VS that static initialization of create_schema and > migrate_schema function initialization This post explains the potential problem with static libraries: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html While this post explains how to fix it in VC++: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001289.html Boris From Harald.Frostel at jku.at Wed Jan 15 09:26:03 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Wed Jan 15 09:26:31 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> Message-ID: <52D6A88B0200004C000AEEBD@gwia.im.jku.at> Hi! I have a problem creating dynamic multi-database query support code with objects that contain composite value members under Visual Studio (MSVC) 2010 and 2013. I created a minimal example to shown the problem with MSVC and SQLite. The same code compiles and runs without problems under Linux/GCC and Apple/Clang. The architecture is as follows (similar to the ODB Manual): - The common layer code is compiled into a shared library (model.dll). - The generated sqlite (or any other) layer code (model-odb-sqlite.cxx, ...) is compiled into model-sqlite.dll and linked against the common layer shared library. - The program (testprogram) links agains the common layer and loads the sqlite layer at runtime. This works without problems for database objects that does not contain composite value members or if no query code is generated. If query code is generated, the linking of the sqlite layer code fails due to unresolved external symbols (under MSVC) for the composite value types. The linking error goes away for some reason, if the database object also contains columns of plain datatypes (e.g. ints) but than the testprogram craches at runtime if a query for that object is executed. To make things easy, the attached minimal example can be build using cmake. I tried the code unter Visual Studio Express 2013 (64 bit compiler) and Visual Studio Express 2010 (32-bit code) and both fail. Under Linux/GCC and Mac/Clang the example works (odb-2.3.0) I'm not sure if this is a bug in odb (2.3.0) or I'm getting something wrong with the EXPORT/EXTERN macros. To test the program simply run cmake and make, and than execute the testprogram binary (if linking works). To remove the linking error of the sqlite shared library code, simply go to line number 87 in model.hxx, remove the comments and watch the testprogram fail. Code: http://www.cp.jku.at/people/frostel/MinimalCompositeTest.zip I hope, somebody can give me any advice! Regards Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** From lidia at lemur-soft.com Wed Jan 15 10:14:58 2014 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Wed Jan 15 10:15:06 2014 Subject: [odb-users] migration compiler problem. In-Reply-To: References: Message-ID: thanks a lot - will try it. On Wed, Jan 15, 2014 at 2:40 PM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > We use odb inside static library. > > > > There is problem in MS VS that static initialization of create_schema and > > migrate_schema function initialization > > This post explains the potential problem with static libraries: > > http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html > > While this post explains how to fix it in VC++: > > http://www.codesynthesis.com/pipermail/odb-users/2013-May/001289.html > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From buptstehc at gmail.com Wed Jan 15 22:15:27 2014 From: buptstehc at gmail.com (=?UTF-8?B?6buE5bed?=) Date: Wed Jan 15 22:16:04 2014 Subject: [odb-users] memory leak In-Reply-To: References: Message-ID: thanks, boris! I have found the problem, it's my programming error, which has nothing to do with odb. 2014/1/15 Boris Kolpackov > Hi, > > ?? writes: > > > Does "an initial increase in resources which stops growing > > over time." means the resources will be released at some time? > > can i release it manually? > > The only sure way to release all the cached resources is to > destroy the odb::database instance (db_ in your case). Even > then it is possible that the underlying database library > (that is, the C API to the database) will still hold some > resources. > > Boris > From boris at codesynthesis.com Thu Jan 16 02:05:09 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 16 02:07:33 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: <52D6A88B0200004C000AEEBD@gwia.im.jku.at> References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > I have a problem creating dynamic multi-database query support code > with objects that contain composite value members under Visual Studio > (MSVC) 2010 and 2013. I managed to reproduce the problem in our own test and I am looking into it. Will keep you posted on the progress. Boris From Aleksey.Enakaev at infotecs.ru Fri Jan 17 05:32:22 2014 From: Aleksey.Enakaev at infotecs.ru (=?UTF-8?B?0JXQvdCw0LrQsNC10LIg0JDQu9C10LrRgdC10Lk=?=) Date: Fri Jan 17 05:42:11 2014 Subject: [odb-users] Problem with using ODB with database connection pooler Message-ID: <52D906B6.4050704@infotecs.ru> Hi. We've got another problem while using ODB. The matter is we use database connection pooler (pgbouncer) in "transaction" mode. It turned out in this kind of mode pgbouncer does not support prepared statements, but ODB manual says "all the non-query database operations such as persist(), load(), update(), etc., are implemented in terms of prepared statements that are cached and reused". The question is if there is some way to prevent using prepared statement with non-query database operations? Best regards. From boris at codesynthesis.com Fri Jan 17 05:57:54 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 17 06:00:18 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> Message-ID: Hi Harald, Ok, I've managed to fix this. I can build you a pre-release binary of the ODB compiler if you would like to test the fix. Just let me know which platform/architecture you are using. For those interested in the gory details, here is some background on the problem/fix from the git log: A composite value is represented in query_columns as a nested struct. Even though the query_columns template instantiation is exported, VC++ for some reason doesn't appear to also export the nested structs. To work around this, nested structs have to have the export macro in the declaration. But that's not it: we also have to declare the nested structs extern, just like the outer template instantiation itself. Boris From boris at codesynthesis.com Fri Jan 17 06:12:21 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 17 06:14:45 2014 Subject: [odb-users] Problem with using ODB with database connection pooler In-Reply-To: <52D906B6.4050704@infotecs.ru> References: <52D906B6.4050704@infotecs.ru> Message-ID: Hi Aleksey, ??????? ??????? writes: > The matter is we use database connection pooler (pgbouncer) in > "transaction" mode. It turned out in this kind of mode pgbouncer > does not support prepared statements, but ODB manual says "all the > non-query database operations such as persist(), load(), update(), > etc., are implemented in terms of prepared statements that are > cached and reused". The question is if there is some way to prevent > using prepared statement with non-query database operations? There is no way to disable prepared statements in ODB (and it would probably be a bad idea from the performance point of view). What you could do, as a workaround, is to make ODB release the connection (and therefore prepared statements) after each transaction. This way it will "match" what pgbouncer is doing. You may end up with pretty poor performance, though. If you want to try this, you can use the new_connection_factory instead of the default connection_pool_factory. See Section 19.3, "PostgreSQL Connection and Connection Factory" for details. On a more general note, you didn't say what you are trying to achieve by using pgbouncer. E.g., is it just a connection pooler to a single server? Or is it used as a load balancer between multiple servers? If it is just a connection pooler (i.e., it is used to reduce the overhead of establishing new connections to PG), then it is not really necessary since the default ODB connection_pool_factory already caches the connections. Even if this is not exactly what you want, you may be able to achieve better results by implementing your own connection_factory (e.g., release connections after some time of inactivity, or some such). I think not being able to use prepared statements is too drastic. Boris From Harald.Frostel at jku.at Fri Jan 17 06:18:15 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Fri Jan 17 06:18:43 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> Message-ID: <52D91F870200004C000AF190@gwia.im.jku.at> Hi Boris, thank you very much for the quick fix! I would be interested in the pre-release binary. My platform is Windows x64. Thanks! Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** >>> Boris Kolpackov 17.01.2014 11:57 >>> Hi Harald, Ok, I've managed to fix this. I can build you a pre-release binary of the ODB compiler if you would like to test the fix. Just let me know which platform/architecture you are using. For those interested in the gory details, here is some background on the problem/fix from the git log: A composite value is represented in query_columns as a nested struct. Even though the query_columns template instantiation is exported, VC++ for some reason doesn't appear to also export the nested structs. To work around this, nested structs have to have the export macro in the declaration. But that's not it: we also have to declare the nested structs extern, just like the outer template instantiation itself. Boris From boris at codesynthesis.com Sat Jan 18 04:12:56 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat Jan 18 04:15:20 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: <52D91F870200004C000AF190@gwia.im.jku.at> References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > I would be interested in the pre-release binary. My platform is Windows x64. Here you go: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.3.1-i686-windows.zip Let me know if there are any problems. And thanks for reporting this bug and providing the test case! Boris From Harald.Frostel at jku.at Tue Jan 21 04:55:59 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Tue Jan 21 04:56:33 2014 Subject: Antw: Re: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> Message-ID: <52DE523F0200004C000AF4A7@gwia.im.jku.at> Hi Boris, I tried the new binary and it seems to work! Thank you! Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** >>> Boris Kolpackov 18.01.2014 10:12 >>> Hi Harald, Harald Frostel writes: > I would be interested in the pre-release binary. My platform is Windows x64. Here you go: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.3.1-i686-windows.zip Let me know if there are any problems. And thanks for reporting this bug and providing the test case! Boris From Harald.Frostel at jku.at Tue Jan 21 15:01:47 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Tue Jan 21 15:02:14 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> Message-ID: <52DEE03B0200004C000AF546@gwia.im.jku.at> Hi Boris, The dynamic multi-database support seems to work, but unfortunately, I realized, that with the new odb-compiler, I run into problems when creating a library without multi-database support. In my case I create a shared library containing static database code for, lets say Sqlite. I use the same export/extern macros as with the dynamic multi-database shared library (common layer). When I try to link this Sqlite/odb shared library to an executable , I get linker errors (Visual Studio) like the following: error C2491: 'odb::query_columns>::id_type_::key1' : definition of dllimport static data member not allowed. I compared the generated code (*-odb.hpp) from your new binary (2.3.1) with the odb 2.3.0 compiler (which works in that case) and it seems that the newly inserted MODEL_EXPORT macro is causing the errors here. template struct query_columns< ::ACompositeObject, id_sqlite, A > { // id // struct MODEL_EXPORT id_type_ // WAS: struct id_type_ { id_type_ () { } ? } So, I'm not sure, if I'm using the export/extern macros correctly in that case or the generated code is causing this issue. Cheers Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** >>> Boris Kolpackov 18.01.2014 10:12 >>> Hi Harald, Harald Frostel writes: > I would be interested in the pre-release binary. My platform is Windows x64. Here you go: http://www.codesynthesis.com/~boris/tmp/odb/odb-2.3.1-i686-windows.zip Let me know if there are any problems. And thanks for reporting this bug and providing the test case! Boris From adrien_chem at hotmail.com Tue Jan 21 16:30:59 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Tue Jan 21 16:31:06 2014 Subject: [odb-users] ODB Compilation under MinGW Message-ID: Hi everyone, I'm trying to compile odb on windows with gcc. So i'm working under the msys environment.What I have to compile is the following :- libodb-2.3.0 OK- libodb-mysql-2.3.0 KO- libodb-sqlite-2.3.0 KO For both KOs, the error are the same, I miss the database specific libraries: configure: error: libmysqlclient_r is not found; consider using CPPFLAGS/LDFLAGS to specify its location So I download here the mysql connector : http://dev.mysql.com/downloads/connector/c/ for linux generic Linux - Generic (glibc 2.5) (x86, 32-bit), Compressed TAR Archive My configure command call is as follow : $./configure CPPFLAGS="-I../libodb-2.3.0/odb -I../../mysqlclient-linux-6.1.3/include" LDFLAGS="-L../../mysqlclient-linux-6.1.3/lib -L../libodb-2.3.0/odb" ls ../../mysqlclient-linux-6.1.3/lib returns :libmysqlclient.a libmysqlclient.so.18.2.0 libmysqlclient_r.so.18libmysqlclient.so libmysqlclient_r.a libmysqlclient_r.so.18.2.0libmysqlclient.so.18 libmysqlclient_r.so So the path seems ok, I have no clue what is wrong now, do you have any idea ? Thank you very much ! :) From boris at codesynthesis.com Wed Jan 22 03:35:45 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 22 03:38:10 2014 Subject: [odb-users] ODB Compilation under MinGW In-Reply-To: References: Message-ID: Hi Adrien, Adrien G writes: > configure: error: libmysqlclient_r is not found > So I download here the mysql connector for linux generic Linux [...] If I undrstand you correctly, you are building on MinGW/Windows and you downloaded a pre-built MySQL library for Linux. That's not going to work. You cannot use Linux libraries on Windows. What you need to do is download the MySQL client for Windows (that was built with VC++). Then rename libmysql.lib to libmysqlclient_r.a. For SQLite, you will need to build the library from source for MinGW. Get the sqlite-autoconf package and then use configure & make under MSYS to build it for MinGW. Boris From boris at codesynthesis.com Wed Jan 22 03:58:16 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 22 04:00:40 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: <52DEE03B0200004C000AF546@gwia.im.jku.at> References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> <52DEE03B0200004C000AF546@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > I use the same export/extern macros as with the dynamic multi-database > shared library (common layer). > > template > struct query_columns< ::ACompositeObject, id_sqlite, A > > { > struct MODEL_EXPORT id_type_ // WAS: struct id_type_ You need to use a separate set of export/extern macros for each DLL that you create. That is, you would have MODEL_EXPORT for the common interface, MODEL_SQLITE_EXPORT for the SQLite implementation, MODEL_MYSQL_EXPORT for MySQL, etc. When you are building the SQLite implementation DLL, MODEL_EXPORT should be set to import while MODEL_SQLITE_EXPORT to export. When building your application, both MODEL_EXPORT and MODEL_SQLITE_EXPORT should be set to import. Can you check this and let me know whether this was the problem? Boris From Harald.Frostel at jku.at Wed Jan 22 05:43:01 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Wed Jan 22 05:43:23 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> <52DEE03B0200004C000AF546@gwia.im.jku.at> Message-ID: <52DFAEC50200004C000AF5C8@gwia.im.jku.at> Hi Boris, yes, I know that this is necessary for the dynamic multi-database support with shared libraries for each layer. This works now with the new compiler binary you sent me. In another case however I don't use dynamic multi-database support. I just generate static database code for Sqlite and pack it into a shared library. Than I want to use this shared library in one or more executables. This case does not work anymore with the new odb compiler. When I compile the Sqlite shared library, I define a BUILD_DLL (MODEL_BUILD_DLL in the test case I sent you) macro which leads to an export of the structs etc. When I build an executable, that uses the shared library, the import macros are used. As far as I can tell this should work and it worked with the official 2.3.0 compiler but not anymore with the 2.3.1 binary you sent me. If I find time today, I'll create a test code for this constellation. Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** >>> Boris Kolpackov 22.01.2014 09:58 >>> Hi Harald, Harald Frostel writes: > I use the same export/extern macros as with the dynamic multi-database > shared library (common layer). > > template > struct query_columns< ::ACompositeObject, id_sqlite, A > > { > struct MODEL_EXPORT id_type_ // WAS: struct id_type_ You need to use a separate set of export/extern macros for each DLL that you create. That is, you would have MODEL_EXPORT for the common interface, MODEL_SQLITE_EXPORT for the SQLite implementation, MODEL_MYSQL_EXPORT for MySQL, etc. When you are building the SQLite implementation DLL, MODEL_EXPORT should be set to import while MODEL_SQLITE_EXPORT to export. When building your application, both MODEL_EXPORT and MODEL_SQLITE_EXPORT should be set to import. Can you check this and let me know whether this was the problem? Boris From boris at codesynthesis.com Wed Jan 22 06:37:06 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 22 06:39:31 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: <52DFAEC50200004C000AF5C8@gwia.im.jku.at> References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> <52DEE03B0200004C000AF546@gwia.im.jku.at> <52DFAEC50200004C000AF5C8@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > In another case however I don't use dynamic multi-database support. > I just generate static database code for Sqlite and pack it into a > shared library. Ok, that case I think I fixed. Can you try the updated binary and let me know: http://codesynthesis.com/~boris/tmp/odb/odb-2.3.1-i686-windows.zip Boris From Harald.Frostel at jku.at Wed Jan 22 09:38:47 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Wed Jan 22 09:39:20 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: References: <52D6A5700200004C000AEE9D@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> <52DEE03B0200004C000AF546@gwia.im.jku.at> <52DFAEC50200004C000AF5C8@gwia.im.jku.at> Message-ID: <52DFE6070200004C000AF639@gwia.im.jku.at> Hi Boris, I tried the new binary and this seems to work now! Just for information on how I use my odb code depending on the use-case (all work now): - Single-Database support code in a shared library - Multi-database support, all layers packed into one single shared library (no extra runtime loading) - Multi-database support, each layer packed into a different shared library and loaded at runtime Thanks again for the quick fix! Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** >>> Boris Kolpackov 22.01.2014 12:37 >>> Hi Harald, Harald Frostel writes: > In another case however I don't use dynamic multi-database support. > I just generate static database code for Sqlite and pack it into a > shared library. Ok, that case I think I fixed. Can you try the updated binary and let me know: http://codesynthesis.com/~boris/tmp/odb/odb-2.3.1-i686-windows.zip Boris From adrien_chem at hotmail.com Wed Jan 22 12:21:56 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Wed Jan 22 12:22:03 2014 Subject: [odb-users] ODB Compilation under MinGW In-Reply-To: References: , Message-ID: Oh ok, I didn't know that I could rename a .lib into .a like that. I'm going to try ! Thank you :) > Date: Wed, 22 Jan 2014 10:35:45 +0200 > From: boris@codesynthesis.com > To: adrien_chem@hotmail.com > CC: odb-users@codesynthesis.com > Subject: Re: [odb-users] ODB Compilation under MinGW > > Hi Adrien, > > Adrien G writes: > > > configure: error: libmysqlclient_r is not found > > So I download here the mysql connector for linux generic Linux [...] > > If I undrstand you correctly, you are building on MinGW/Windows and you > downloaded a pre-built MySQL library for Linux. That's not going to work. > You cannot use Linux libraries on Windows. > > What you need to do is download the MySQL client for Windows (that was > built with VC++). Then rename libmysql.lib to libmysqlclient_r.a. > > For SQLite, you will need to build the library from source for MinGW. > Get the sqlite-autoconf package and then use configure & make under > MSYS to build it for MinGW. > > Boris From adrien_chem at hotmail.com Wed Jan 22 14:29:45 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Wed Jan 22 14:29:52 2014 Subject: [odb-users] ODB Compilation under MinGW In-Reply-To: References: , , , Message-ID: That's weird, same problem occures... :/ > From: adrien_chem@hotmail.com > To: odb-users@codesynthesis.com > Subject: RE: [odb-users] ODB Compilation under MinGW > Date: Wed, 22 Jan 2014 18:21:56 +0100 > > Oh ok, I didn't know that I could rename a .lib into .a like that. I'm going to try ! > Thank you :) > > > Date: Wed, 22 Jan 2014 10:35:45 +0200 > > From: boris@codesynthesis.com > > To: adrien_chem@hotmail.com > > CC: odb-users@codesynthesis.com > > Subject: Re: [odb-users] ODB Compilation under MinGW > > > > Hi Adrien, > > > > Adrien G writes: > > > > > configure: error: libmysqlclient_r is not found > > > So I download here the mysql connector for linux generic Linux [...] > > > > If I undrstand you correctly, you are building on MinGW/Windows and you > > downloaded a pre-built MySQL library for Linux. That's not going to work. > > You cannot use Linux libraries on Windows. > > > > What you need to do is download the MySQL client for Windows (that was > > built with VC++). Then rename libmysql.lib to libmysqlclient_r.a. > > > > For SQLite, you will need to build the library from source for MinGW. > > Get the sqlite-autoconf package and then use configure & make under > > MSYS to build it for MinGW. > > > > Boris > From boris at codesynthesis.com Thu Jan 23 02:20:48 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 23 02:23:12 2014 Subject: [odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC) In-Reply-To: <52DFE6070200004C000AF639@gwia.im.jku.at> References: <52D6A88B0200004C000AEEBD@gwia.im.jku.at> <52D91F870200004C000AF190@gwia.im.jku.at> <52DEE03B0200004C000AF546@gwia.im.jku.at> <52DFAEC50200004C000AF5C8@gwia.im.jku.at> <52DFE6070200004C000AF639@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > I tried the new binary and this seems to work now! > > Just for information on how I use my odb code depending on the > use-case (all work now): > > [...] Great, thanks for your help in tracking this down! Boris From boris at codesynthesis.com Thu Jan 23 02:27:09 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 23 02:29:33 2014 Subject: [odb-users] ODB Compilation under MinGW In-Reply-To: References: Message-ID: Hi Adrien, Adrien G writes: > That's weird, same problem occures... :/ Assuming you put your MySQL client in C:\mysql with headers in C:\mysql\include and libraries in C:\mysql\lib, try this command line when configuring libodb-mysql: ./configure CPPFLAGS="-I/c/mysql/include ..." LDFLAGS="-L/c/mysql/lib ..." (here "..." standad for the rest of the options, for example, for libodb, etc). If this still doesn't work, take a look at the config.log file. It contains actual g++ commands run by configure as well as the actual error messages (start from the bottom of the file and scroll up until you see a compiler error). Boris From Aleksey.Enakaev at infotecs.ru Fri Jan 24 01:37:52 2014 From: Aleksey.Enakaev at infotecs.ru (=?UTF-8?B?0JXQvdCw0LrQsNC10LIg0JDQu9C10LrRgdC10Lk=?=) Date: Fri Jan 24 08:33:53 2014 Subject: [odb-users] DISTINCT clause usage problem Message-ID: <52E20A40.4000304@infotecs.ru> Hi! Tell me please, if there is any way to create ODB object view with 'DISTINCT' clause on some column: 'SELECT DISTINCT ON( id ) id, name, some_other_fileld FROM table1 JOIN table2 ...'? ODB object view described like this: #pragma db object view( Company ) \ object( Person: Person::company_id == Company::company_id ) struct CompanyByPerson { uuid company_id; // company columns // ... // person columns // ... }; Best regards. -- ? ?????????, ??????? ???????. ????? ?????. From boris at codesynthesis.com Fri Jan 24 08:47:03 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 24 08:49:27 2014 Subject: [odb-users] DISTINCT clause usage problem In-Reply-To: <52E20A40.4000304@infotecs.ru> References: <52E20A40.4000304@infotecs.ru> Message-ID: Hi Aleksey, ??????? ??????? writes: > Tell me please, if there is any way to create ODB object view with > 'DISTINCT' clause on some column: > > 'SELECT DISTINCT ON( id ) id, name, some_other_fileld FROM table1 > JOIN table2 ...'? Unfortunately, because DISTINCT comes between SELECT and the select- list, there is no way to use it with an object view. So your options are: 1. Use a native view (Section 10.5) and specify the complete query. 2. Find a way to re-implement your query as a suffix for the WHERE clause. For example, using EXISTS. Boris From xdsecret1 at gmail.com Sat Jan 25 11:56:46 2014 From: xdsecret1 at gmail.com (xudong) Date: Sat Jan 25 11:58:37 2014 Subject: [odb-users] memory leak for odd in mfc project Message-ID: <78D08EDC-EC6D-464D-B4E8-EED8D11B8E2C@gmail.com> I am a newbie for ODB library, I have a project use ODB with mysql support. When I compile a simple application with MFC framework, the memory leak is detected, but when i compile the application with win32 console, it has no memory leak. follow is the logs from the Visual studio 2008 ouput window: "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\mfctest.exe?? "mfctest.exe?: "C:\Windows\System32\ntdll.dll? "mfctest.exe?: "C:\Windows\System32\kernel32.dll? "mfctest.exe?: "C:\Windows\System32\KernelBase.dll? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\odb-mysql-d-2.0-vc9.dll?? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\odb-d-2.0-vc9.dll?? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcr90d.dll? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcp90d.dll?? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\libmysql.dll? "mfctest.exe?: "C:\Windows\System32\user32.dll? "mfctest.exe?: "C:\Windows\System32\gdi32.dll? "mfctest.exe?: "C:\Windows\System32\lpk.dll? "mfctest.exe?: "C:\Windows\System32\usp10.dll? "mfctest.exe?: "C:\Windows\System32\msvcrt.dll? "mfctest.exe?: "C:\Windows\System32\advapi32.dll? "mfctest.exe?: "C:\Windows\System32\sechost.dll? "mfctest.exe?: "C:\Windows\System32\rpcrt4.dll? "mfctest.exe?: "C:\Windows\System32\ws2_32.dll? "mfctest.exe?: "C:\Windows\System32\nsi.dll? "mfctest.exe?: "E:\Temp\ODB\odb-study\hello\Debug\db.dll?? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2f2f658c522a659b\mfc90ud.dll?? "mfctest.exe?: "C:\Windows\System32\shlwapi.dll? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll? "mfctest.exe?: "C:\Windows\System32\msimg32.dll? "mfctest.exe?: "C:\Windows\System32\oleaut32.dll? "mfctest.exe?: "C:\Windows\System32\ole32.dll? "mfctest.exe?: "C:\Windows\System32\imm32.dll? "mfctest.exe?: "C:\Windows\System32\msctf.dll? "mfctest.exe?: "C:\Windows\System32\nlaapi.dll? "mfctest.exe?: "C:\Windows\System32\NapiNSP.dll? "mfctest.exe?: "C:\Windows\System32\pnrpnsp.dll? "mfctest.exe?: "C:\Windows\System32\mswsock.dll? "mfctest.exe?: "C:\Windows\System32\dnsapi.dll? "mfctest.exe?: "C:\Windows\System32\winrnr.dll? "mfctest.exe?: "C:\Windows\System32\rasadhlp.dll? "mfctest.exe?: "C:\Windows\System32\uxtheme.dll? "mfctest.exe?: "C:\Windows\System32\dwmapi.dll? "mfctest.exe?: "C:\Windows\winsxs\x86_microsoft.vc90.mfcloc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_49768ef57548175e\MFC90CHS.DLL????????????????? "mfctest.exe?: "C:\Windows\System32\shell32.dll? "mfctest.exe?: "C:\Windows\System32\cryptbase.dll? "mfctest.exe?: "C:\Windows\System32\clbcatq.dll? Detected memory leaks! Dumping objects -> {143} normal block at 0x00645670, 40 bytes long. Data: < > 03 00 00 00 00 00 00 00 CD CD CD CD 00 CD CD CD {142} normal block at 0x00645600, 52 bytes long. Data: < Rd Td Rd > F0 52 64 00 B0 54 64 00 F0 52 64 00 00 00 00 00 {141} normal block at 0x00645590, 52 bytes long. Data: < Ud Sd `Sd > 20 55 64 00 D0 53 64 00 60 53 64 00 00 00 00 00 {140} normal block at 0x00645520, 52 bytes long. Data: < Rd Ud Rd > F0 52 64 00 90 55 64 00 F0 52 64 00 00 00 00 00 {139} normal block at 0x006454B0, 52 bytes long. Data: <@Td Sd Vd > 40 54 64 00 D0 53 64 00 00 56 64 00 00 00 00 00 {138} normal block at 0x00645440, 52 bytes long. Data: < Rd Td Rd > F0 52 64 00 B0 54 64 00 F0 52 64 00 00 00 00 00 {137} normal block at 0x006453D0, 52 bytes long. Data: < Td Rd Ud > B0 54 64 00 F0 52 64 00 90 55 64 00 00 00 00 00 {136} normal block at 0x00645360, 52 bytes long. Data: < Rd Ud Rd > F0 52 64 00 90 55 64 00 F0 52 64 00 00 00 00 00 {135} normal block at 0x006452F0, 52 bytes long. Data: <@Td Sd `Sd > 40 54 64 00 D0 53 64 00 60 53 64 00 CD CD CD CD {134} normal block at 0x00645288, 40 bytes long. Data: < HRd wRQ> 01 00 00 00 04 00 00 00 48 52 64 00 E9 77 52 51 {133} normal block at 0x00645248, 1 bytes long. Data: < > 00 {131} normal block at 0x00645130, 24 bytes long. Data: < wRQ > 01 00 00 00 04 00 00 00 E9 77 52 51 00 00 00 00 {130} normal block at 0x006450B0, 68 bytes long. Data: < Pd Pd Pd > B0 50 64 00 B0 50 64 00 B0 50 64 00 CD CD CD CD {129} normal block at 0x00645058, 28 bytes long. Data: < > 00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD Object dump complete. From adrien_chem at hotmail.com Sun Jan 26 13:54:42 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Sun Jan 26 13:54:50 2014 Subject: [odb-users] ODB Compilation under MinGW In-Reply-To: References: , , , , Message-ID: Oh thanks it's working fine. I guess the problem was the relative path :) Okay I'm gonna compile sqlite, I let you know if I hit some problems :) Thanks again. > Date: Thu, 23 Jan 2014 09:27:09 +0200 > From: boris@codesynthesis.com > To: adrien_chem@hotmail.com > CC: odb-users@codesynthesis.com > Subject: Re: [odb-users] ODB Compilation under MinGW > > Hi Adrien, > > Adrien G writes: > > > That's weird, same problem occures... :/ > > Assuming you put your MySQL client in C:\mysql with headers in > C:\mysql\include and libraries in C:\mysql\lib, try this command > line when configuring libodb-mysql: > > ./configure CPPFLAGS="-I/c/mysql/include ..." LDFLAGS="-L/c/mysql/lib ..." > > (here "..." standad for the rest of the options, for example, for > libodb, etc). > > If this still doesn't work, take a look at the config.log file. > It contains actual g++ commands run by configure as well as the > actual error messages (start from the bottom of the file and > scroll up until you see a compiler error). > > Boris From Harald.Frostel at jku.at Mon Jan 27 04:16:11 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Mon Jan 27 04:16:37 2014 Subject: [odb-users] Object reference in composite value type Message-ID: <52E631EB0200004C000AFA36@gwia.im.jku.at> Hi! Is there a way to use a shared_ptr/lazy_shared_ptr in a composite value? In our database we use composite primary keys quite a lot. In most cases we have collections of "child" objects that belong to a "parent" object (1-n relationship). The child?s primary key consists of the parent primary key and a child id that is unique within one parent. Example: Parent Table: ID Values 1 ? 2 ? PRIMARY KEY("ID"), Child Table: ParentID ChildID Values 1 1 ? 1 2 ? 1 3 ? 2 1 ? PRIMARY KEY("ParentID","ChildID"), FOREIGN KEY ("ParentID") REFERENCES "ParentTable" ("ID") The straight forward way for the child object would be to create a composite value that consists of a reference to a parent object and a child id, and use this as the id in the child object. #pragma db value struct ChildCompositePrimaryKey { private: friend class odb::access; public: #pragma db column("ParentID") not_null std::shared_ptr parent__; #pragma db column("ChildID") not_null int child_id_; }; But when this is compiled with the odb compiler, I get an error: error: object pointer member 'parent_' in a composite value type that is used as an object id. The workaround right now is to use custom set/get methods (replace the reference in the composite value by an int parent_id_ and create a lazy_pointer of this parent id during loading) for the child object id but than, in the generate schema the foreign key relation is lost. Is there a way to solve this differently (without changing the schema of the database)? Regards, Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** From alon.moshayov at myheritage.com Mon Jan 27 04:36:03 2014 From: alon.moshayov at myheritage.com (Alon Moshayov) Date: Mon Jan 27 14:12:57 2014 Subject: [odb-users] Persist Google's Protocol Buffers... Message-ID: Hi, I'm looking for an ability to persist Google's Protocol Buffers with ODB to SQLite database. Does ODB capable to accept protocol classes and generate corresponding database support code? Thanks Alon... From adrien_chem at hotmail.com Mon Jan 27 18:24:15 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Mon Jan 27 18:24:22 2014 Subject: [odb-users] Generate C++ classes from a DB Message-ID: Hey ! Do you have some command examples to generate the C++ model that reflects an existing DB ? For example I'd like to generate C++ classes (using Qt bindings) to match an sqlite and mysql DB. I'm reading the man of the odb compiler but it's kind of empirical :) Thank you for your help :) From boris at codesynthesis.com Mon Jan 27 23:18:39 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 27 23:16:32 2014 Subject: [odb-users] Object reference in composite value type In-Reply-To: <52E631EB0200004C000AFA36@gwia.im.jku.at> References: <52E631EB0200004C000AFA36@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > Is there a way to use a shared_ptr/lazy_shared_ptr in a composite > value? You can use object pointers in composite values. What you are looking for is using object pointers in (composite) object ids. This is currently not supported though we are planning to support this at some point. > The workaround right now is to use custom set/get methods (replace the > reference in the composite value by an int parent_id_ and create a > lazy_pointer of this parent id during loading) for the child object id > but than, in the generate schema the foreign key relation is lost. You could also go one step further and use a virtual data member for parent_id (and a transient pointer member). This way you will end up with a single physical data member (pointer) instead of two. But yes, the foreign key semantics in the schema is lost with this approach. > Is there a way to solve this differently (without changing the schema > of the database)? The database schema that you are trying to re-create is very similar to what one gets when using a container. So you may want to consider making your child object actually a (composite) value and then have a container of those in the parent object. Boris From boris at codesynthesis.com Mon Jan 27 23:32:43 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 27 23:30:36 2014 Subject: [odb-users] Persist Google's Protocol Buffers... In-Reply-To: References: Message-ID: Hi Alon, Alon Moshayov writes: > I'm looking for an ability to persist Google's Protocol Buffers with > ODB to SQLite database. > Does ODB capable to accept protocol classes and generate corresponding > database support code? I believe several people tried this and it is possible. You will need to map the generated protobuffer classes for ODB. That is, specify which classes are persistent, what are their ids, etc. This can be done completely unintrusively (so you don't need to modify the generated files), as described at the beginning of Chapter 14, "ODB Pragma Language". Also, the recently added support for automatic discovery of suitable accessors and modifiers should make this mapping really easy. In most cases I would expect all you need to do is have two pragmas like these for each persistent class: #pragma db object(Foo) #pragma db member(Foo:id) id Also, here is a previous thread on the same topic with some more background information (note that the virtual data members feature mentioned there is now supported): http://www.codesynthesis.com/pipermail/odb-users/2011-October/000352.html Boris From boris at codesynthesis.com Mon Jan 27 23:40:47 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 27 23:38:39 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: References: Message-ID: Hi Adrien, Adrien G writes: > Do you have some command examples to generate the C++ model that reflects an > existing DB? For example I'd like to generate C++ classes (using Qt > bindings) to match an sqlite and mysql DB. No, this is not supported, though it is on our TODO list. The problem with this feature is that it is not exactly clear how to map tables to classes in many cases. Mapping for things like relationships and containers are not easy to deduce from the database schema. Also, you seem to want to go a step further and have generated classes that simultaneously match two schemas for two different databases. I don't think we will ever support something like this; it is too AI'ish. Note also that you can always write the classes by hand and then map them to your existing schema(s). In your case, while it may seem like a tedious approach, it is probably the only one that has a chance of actually working. Boris From boris at codesynthesis.com Mon Jan 27 23:43:20 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 27 23:41:13 2014 Subject: [odb-users] memory leak for odd in mfc project In-Reply-To: <78D08EDC-EC6D-464D-B4E8-EED8D11B8E2C@gmail.com> References: <78D08EDC-EC6D-464D-B4E8-EED8D11B8E2C@gmail.com> Message-ID: Hi, Sorry for the delay in getting your post through to the mailing list. It got caught up in our spam filter and we only discovered the mistake now. Are you still having problems using ODB with MFC or have you managed to resolve this? Boris From adrien_chem at hotmail.com Tue Jan 28 03:23:12 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Tue Jan 28 03:24:24 2014 Subject: [odb-users] Generate C++ classes from a DB Message-ID: Thanks for your answer! Indeed i guess this is a tricky feature to implement ^^ No i didnt want to link two db at once its actually two different projects ;) Once that said, imagine you have a db with hundred of tables, its insane to code it by hand, for time and human errors reasons ^^ do you have a roadmap for this feature ? Is there any other c++ lib which supports this ? Thanks and good luck :) Sent from my Windows Phone ________________________________ From: Boris Kolpackov Sent: ?28/?01/?2014 05:38 To: Adrien G Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Generate C++ classes from a DB Hi Adrien, Adrien G writes: > Do you have some command examples to generate the C++ model that reflects an > existing DB? For example I'd like to generate C++ classes (using Qt > bindings) to match an sqlite and mysql DB. No, this is not supported, though it is on our TODO list. The problem with this feature is that it is not exactly clear how to map tables to classes in many cases. Mapping for things like relationships and containers are not easy to deduce from the database schema. Also, you seem to want to go a step further and have generated classes that simultaneously match two schemas for two different databases. I don't think we will ever support something like this; it is too AI'ish. Note also that you can always write the classes by hand and then map them to your existing schema(s). In your case, while it may seem like a tedious approach, it is probably the only one that has a chance of actually working. Boris From johannes.lochmann at gmail.com Tue Jan 28 04:27:12 2014 From: johannes.lochmann at gmail.com (Johannes Lochmann) Date: Tue Jan 28 04:27:20 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: References: Message-ID: If it is only for plain data structs vor classes this could be achieved quite easily with a scripting language of your choice and a bit of SQL, i guess... Am 28.01.2014 09:24 schrieb "Adrien G" : > Thanks for your answer! Indeed i guess this is a tricky feature to > implement ^^ No i didnt want to link two db at once its actually two > different projects ;) > Once that said, imagine you have a db with hundred of tables, its insane > to code it by hand, for time and human errors reasons ^^ do you have a > roadmap for this feature ? Is there any other c++ lib which supports this ? > > Thanks and good luck :) > > Sent from my Windows Phone > ________________________________ > From: Boris Kolpackov > Sent: 28/01/2014 05:38 > To: Adrien G > Cc: odb-users@codesynthesis.com > Subject: Re: [odb-users] Generate C++ classes from a DB > > Hi Adrien, > > Adrien G writes: > > > Do you have some command examples to generate the C++ model that > reflects an > > existing DB? For example I'd like to generate C++ classes (using Qt > > bindings) to match an sqlite and mysql DB. > > No, this is not supported, though it is on our TODO list. The problem > with this feature is that it is not exactly clear how to map tables to > classes in many cases. Mapping for things like relationships and > containers are not easy to deduce from the database schema. Also, you > seem to want to go a step further and have generated classes that > simultaneously match two schemas for two different databases. I don't > think we will ever support something like this; it is too AI'ish. > > Note also that you can always write the classes by hand and then map > them to your existing schema(s). In your case, while it may seem like > a tedious approach, it is probably the only one that has a chance of > actually working. > > Boris > From Harald.Frostel at jku.at Tue Jan 28 04:36:06 2014 From: Harald.Frostel at jku.at (Harald Frostel) Date: Tue Jan 28 04:36:26 2014 Subject: [odb-users] Object reference in composite value type In-Reply-To: References: <52E631EB0200004C000AFA36@gwia.im.jku.at> Message-ID: <52E788160200004C000AFB5B@gwia.im.jku.at> Hi Boris, > You can use object pointers in composite values. What you are looking > for is using object pointers in (composite) object ids. This is > currently not supported though we are planning to support this at > some point. One very helpful feature would be the ability to specify more than one class member as ID. Than the definition of composite values would be obsolete in a lot of cases (e.g. could be generated by the compiler). One (slightly different) problem I encounter with composite values (object ids) is, that the column names are fixed in a composite value. If an object has a composite primary key with the columns lets say {ID1, ID2} and I reference it with a pointer in another object, this object has to have the column names {ID1, ID2} or {Prefix_ID1, Prefix_ID2}. That is ok, if I create the database schema and objects together but can be difficult if I have to wrap the object model around an existing schema, where the column names are different. Than I have to create a foreign-key-composite value struct and a virtual data member for the referencing class. > You could also go one step further and use a virtual data member > for parent_id (and a transient pointer member). This way you will > end up with a single physical data member (pointer) instead of two. > But yes, the foreign key semantics in the schema is lost with this > approach. Right now, I'm actually using the virtual member solution. It works, but yes, the foreign key constraint is lost and I cannot use the reference in a query (e.g. query::parent_->some_value==x). I haven't thought this through completely yet but the id pragma for multiple members would solve this, I guess. > The database schema that you are trying to re-create is very similar > to what one gets when using a container. So you may want to consider > making your child object actually a (composite) value and then have > a container of those in the parent object. Yes, that could work. I think I dropped this solution because the generated schema is not exactly the same (ChildID is the only primary key), but I have to check. Regards Harald **************************************************** Dipl.-Ing. Harald Frostel Department of Computational Perception Johannes Kepler University Linz Altenberger Strasse 69 A-4040 Linz, Austria Tel: +43 732 2468 1521 Fax: +43 732 2468 1520 Mail: harald.frostel@jku.at http://www.cp.jku.at/people/frostel **************************************************** >>> Boris Kolpackov 28.01.2014 05:18 >>> Hi Harald, Harald Frostel writes: > Is there a way to use a shared_ptr/lazy_shared_ptr in a composite > value? You can use object pointers in composite values. What you are looking for is using object pointers in (composite) object ids. This is currently not supported though we are planning to support this at some point. > The workaround right now is to use custom set/get methods (replace the > reference in the composite value by an int parent_id_ and create a > lazy_pointer of this parent id during loading) for the child object id > but than, in the generate schema the foreign key relation is lost. You could also go one step further and use a virtual data member for parent_id (and a transient pointer member). This way you will end up with a single physical data member (pointer) instead of two. But yes, the foreign key semantics in the schema is lost with this approach. > Is there a way to solve this differently (without changing the schema > of the database)? The database schema that you are trying to re-create is very similar to what one gets when using a container. So you may want to consider making your child object actually a (composite) value and then have a container of those in the parent object. Boris From andy.hoffmeyer at turnkeycorrections.com Tue Jan 28 09:08:12 2014 From: andy.hoffmeyer at turnkeycorrections.com (Andrew Hoffmeyer) Date: Tue Jan 28 09:08:23 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: References: Message-ID: <52E7B9CC.6020509@turnkeycorrections.com> I've developed my own pseudo-orm system to do this with a MySQL database, with a good deal of success. it uses the information_schema database, which most modern RDBMSs have. the code generator is written in C++, and uses a custom C++ wrapper that I wrote for the MySQL C API. it handles one-to-many foreign key relationships in both directions, but others are not directly supported yet, although I intend to make them work eventually. I'd say it only took me a total of about a week of actual coding to develop it. I'm not bragging, but rather illustrating that it's not impossible, or even difficult to do, if you have a little motivation and some spare time. I have considered making an odb version of it, but just haven't had the time or ambition to do so. if I ever do, I'll be happy to share the code. I wish I could share what I have, but it is proprietary, and covered by the NDA I have at my job. On 1/28/2014 3:27 AM, Johannes Lochmann wrote: > If it is only for plain data structs vor classes this could be achieved > quite easily with a scripting language of your choice and a bit of SQL, i > guess... > Am 28.01.2014 09:24 schrieb "Adrien G" : > >> Thanks for your answer! Indeed i guess this is a tricky feature to >> implement ^^ No i didnt want to link two db at once its actually two >> different projects ;) >> Once that said, imagine you have a db with hundred of tables, its insane >> to code it by hand, for time and human errors reasons ^^ do you have a >> roadmap for this feature ? Is there any other c++ lib which supports this ? >> >> Thanks and good luck :) >> >> Sent from my Windows Phone >> ________________________________ >> From: Boris Kolpackov >> Sent: 28/01/2014 05:38 >> To: Adrien G >> Cc: odb-users@codesynthesis.com >> Subject: Re: [odb-users] Generate C++ classes from a DB >> >> Hi Adrien, >> >> Adrien G writes: >> >>> Do you have some command examples to generate the C++ model that >> reflects an >>> existing DB? For example I'd like to generate C++ classes (using Qt >>> bindings) to match an sqlite and mysql DB. >> No, this is not supported, though it is on our TODO list. The problem >> with this feature is that it is not exactly clear how to map tables to >> classes in many cases. Mapping for things like relationships and >> containers are not easy to deduce from the database schema. Also, you >> seem to want to go a step further and have generated classes that >> simultaneously match two schemas for two different databases. I don't >> think we will ever support something like this; it is too AI'ish. >> >> Note also that you can always write the classes by hand and then map >> them to your existing schema(s). In your case, while it may seem like >> a tedious approach, it is probably the only one that has a chance of >> actually working. >> >> Boris >> -- Andrew Hoffmeyer Software Developer/Network Administrator Turnkey Corrections/Turnkey Software Solutions V: 715-386-5700 F: 715-386-9988 From mmhess at sandia.gov Tue Jan 28 16:02:13 2014 From: mmhess at sandia.gov (Hess, Michael M) Date: Tue Jan 28 16:02:34 2014 Subject: [odb-users] C compiler cannot create executables Message-ID: Greetings! I'm currently evaluating ODB and its use on one of our projects; and I am configuring the ODB Common Library, via ./configure command. But I am running into the following error: mmhess@coi2:~/downloads/odb/libodb-2.3.0$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking how to create a ustar tar archive... gnutar checking for style of include used by make... GNU checking for gcc... gcc checking whether the C compiler works... no configure: error: in `/home/mmhess/downloads/odb/libodb-2.3.0': configure: error: C compiler cannot create executables See `config.log' for more details As can be seen in the attached config.log file, configure attempts to compile conftest.c, but fails. What might be the cause? The environment we use for our ODB evaluation is: Ubuntu-release 12.04; ODB release 2.3.0. Thanks in advance for any shared information. Michael M. Hess Sandia National Laboratories P.O. Box 5800 Albuquerque, New Mexico 85185-0975 Office Phone: 505.845.8850 -------------- next part -------------- A non-text attachment was scrubbed... Name: config.log.zip Type: application/x-zip-compressed Size: 3236 bytes Desc: config.log.zip Url : http://codesynthesis.com/pipermail/odb-users/attachments/20140128/d3fd9200/config.log.bin From simon.gutierrez.brida at gmail.com Tue Jan 28 20:14:06 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Tue Jan 28 20:14:14 2014 Subject: [odb-users] XML type for a class member using ODB and postgresql Message-ID: Hi, I want to write #pragma db type("XML") std::string data; But when I compile with odb I get error: unknown PostgreSQL type 'XML' Even though I can create a database in postgresql with a table that have a XML column (using pgAdmin) I downloaded libodb-pgsql-2.3.1 db library (it appears to be the latest version) Is there anything special one must do to make the code I put in the beginning work? Regards From alon.moshayov at myheritage.com Tue Jan 28 10:18:57 2014 From: alon.moshayov at myheritage.com (Alon Moshayov) Date: Wed Jan 29 02:03:36 2014 Subject: [odb-users] Persist Google's Protocol Buffers... In-Reply-To: References: Message-ID: Boris, Thanks a lot for your response ... I'm now trying to compile a protocol buffer source header with ODB complier and facing several mapping issues of: - ::google::protobuf::UnknownFieldSet - ::std::string* - ::google::protobuf::RepeatedPtrField - ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32] How should I map these types into ODB (SQLite) corresponding ones Alon... On Tue, Jan 28, 2014 at 6:32 AM, Boris Kolpackov wrote: > Hi Alon, > > Alon Moshayov writes: > > > I'm looking for an ability to persist Google's Protocol Buffers with > > ODB to SQLite database. > > Does ODB capable to accept protocol classes and generate corresponding > > database support code? > > I believe several people tried this and it is possible. You will need > to map the generated protobuffer classes for ODB. That is, specify > which classes are persistent, what are their ids, etc. This can be > done completely unintrusively (so you don't need to modify the > generated files), as described at the beginning of Chapter 14, > "ODB Pragma Language". > > Also, the recently added support for automatic discovery of suitable > accessors and modifiers should make this mapping really easy. In most > cases I would expect all you need to do is have two pragmas like these > for each persistent class: > > #pragma db object(Foo) > #pragma db member(Foo:id) id > > Also, here is a previous thread on the same topic with some more > background information (note that the virtual data members feature > mentioned there is now supported): > > http://www.codesynthesis.com/pipermail/odb-users/2011-October/000352.html > > Boris > From boris at codesynthesis.com Wed Jan 29 02:16:04 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 29 02:14:01 2014 Subject: [odb-users] C compiler cannot create executables In-Reply-To: References: Message-ID: Hi Michael, Hess, Michael M writes: > As can be seen in the attached config.log file, configure attempts > to compile conftest.c, but fails. Thanks for providing the log. It appears that configure picks up the internal version of GCC that is used by ODB: /opt/odb-2.3.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/bin/gcc And it does this because you have added its directory to your PATH: PATH: /opt/odb-2.3.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/bin This should not be necessary and is generally a bad idea since it "hides" your system GCC. Any reason why you went to the trouble of finding and adding this directory to PATH? Boris From boris at codesynthesis.com Wed Jan 29 02:31:38 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 29 02:29:35 2014 Subject: [odb-users] XML type for a class member using ODB and postgresql In-Reply-To: References: Message-ID: Hi, Sim?n Emmanuel Guti?rrez Brida writes: > #pragma db type("XML") > std::string data; > > But when I compile with odb I get > > error: unknown PostgreSQL type 'XML' In ODB database types like PG XML are called "extended database types" and are no mapped automatically (there are too many such types and different applications often require different mappings). Instead, what ODB does is provide a generic mechanism that allows you to map any extended database type to any C++ type via one of the "core database types" that are natively supported by ODB. This article describes this mechanism in detail: http://www.codesynthesis.com/~boris/blog/2012/07/18/custom-database-to-cxx-type-mapping-in-odb/ In your case, you can use TEXT as the core type and the mapping expression could look something like this (based on the PG docs, I haven't tested it myself): #pragma db map type("XML") \ as("TEXT") \ to("XMLPARSE(DOCUMENT (?))") \ from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") Let us know if this works for you. Boris From boris at codesynthesis.com Wed Jan 29 04:01:10 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 29 03:59:09 2014 Subject: [odb-users] Persist Google's Protocol Buffers... In-Reply-To: References: Message-ID: Hi Alon, Alon Moshayov writes: > I'm now trying to compile a protocol buffer source header with ODB complier > and facing several mapping issues of: There will most likely be some data members that are used for protobuf's house-keeping and which should probably not be stored in the database. You will need to mark such data members as transient, for example: #pragma db member(Foo:bar) transient > - ::google::protobuf::UnknownFieldSet >From the protobuf's documentation: "UnknownFieldSet is used to keep track of fields which were seen when parsing a protocol message but whose field numbers or types are unrecognized." You probably don't want to store it in the database. > - ::std::string* What is the semantics of this data member? Does it store actual data? Is it dynamically allocated and if so, by whom? Are there accessors/modifiers that can be used to get/set this data? > - ::google::protobuf::RepeatedPtrField Again, by reading the protobuf's documentation, this class template (and RepeatedField) are containers. You will need to provide a container traits specialization for these class templates in order for ODB to recognize them as containers. This is pretty simple to do and you can see the example of how this is done for std::vector in libodb/odb/std-vector-traits.hxx. If you save your implementation to, say, protobuf-container-traits.hxx, then you can include it into the ODB compilation using the --hxx-prologue option: odb --hxx-prologue "#include \"protobuf-container-traits.hxx.hxx\"" ... > - ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32] You will need to check what the semantics of this array is. My guess is that it is a vector of bit flags that specify whether the optional members are present. Im this case you don't want to store it in the database. Boris From mmhess at sandia.gov Wed Jan 29 09:19:28 2014 From: mmhess at sandia.gov (Hess, Michael M) Date: Wed Jan 29 09:19:51 2014 Subject: [EXTERNAL] Re: [odb-users] C compiler cannot create executables In-Reply-To: References: Message-ID: Boris, in regards to your question below, I included '/opt/odb-2.3.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/bin' in my $PATH since our original Ubuntu environment did not have gcc and g++ installed. As such, I updated my $PATH, installed both gcc and g++, and now the 'configure', 'make' and 'make install' work well. Thank you very much for your prompt response, and have a great day! -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, January 29, 2014 12:16 AM To: Hess, Michael M Cc: odb-users@codesynthesis.com Subject: [EXTERNAL] Re: [odb-users] C compiler cannot create executables Hi Michael, Hess, Michael M writes: > As can be seen in the attached config.log file, configure attempts to > compile conftest.c, but fails. Thanks for providing the log. It appears that configure picks up the internal version of GCC that is used by ODB: /opt/odb-2.3.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/bin/gcc And it does this because you have added its directory to your PATH: PATH: /opt/odb-2.3.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/bin This should not be necessary and is generally a bad idea since it "hides" your system GCC. Any reason why you went to the trouble of finding and adding this directory to PATH? Boris From boris at codesynthesis.com Wed Jan 29 10:38:32 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 29 10:36:30 2014 Subject: [odb-users] Object reference in composite value type In-Reply-To: <52E788160200004C000AFB5B@gwia.im.jku.at> References: <52E631EB0200004C000AFA36@gwia.im.jku.at> <52E788160200004C000AFB5B@gwia.im.jku.at> Message-ID: Hi Harald, Harald Frostel writes: > One very helpful feature would be the ability to specify more than one class > member as ID. Than the definition of composite values would be obsolete in a > lot of cases (e.g. could be generated by the compiler). Yes, I thought about it but it is a lot trickier than what may seem. ODB passes/returns object ids in a lot of places. So there has to be a single "id type" of some kind. You suggested that the ODB compiler automatically generate such a type and that was the idea I initially had. But things start falling apart once you consider relationships that span multiple header files. The second file needs to somehow "see" the generated composite id type during ODB compilation. We also cannot generate two copies and there is no way for ODB to see generated code from another compilation process. As you can see, things get very complicated very fast. So at the moment one has to define a composite value manually. Things that may alleviate some of the burden are the ability to define a composite value as a class template instantiations as well as the ability to define composite values as nested classes inside persistent classes (Section 7.2, "Composite Value Types"). > One (slightly different) problem I encounter with composite values (object > ids) is, that the column names are fixed in a composite value. If an object > has a composite primary key with the columns lets say {ID1, ID2} and I > reference it with a pointer in another object, this object has to have the > column names {ID1, ID2} or {Prefix_ID1, Prefix_ID2}. That is ok, if I create > the database schema and objects together but can be difficult if I have to > wrap the object model around an existing schema, where the column names are > different. Than I have to create a foreign-key-composite value struct and a > virtual data member for the referencing class. Yes, if there is no regularity in column naming in your schema, then this can be a bit of an inconvenience. > I haven't thought this through completely yet but the id pragma > for multiple members would solve this, I guess. No, to get the primary key you need to use object pointers. > Yes, that could work. I think I dropped this solution because the > generated schema is not exactly the same (ChildID is the only primary > key), but I have to check. Actually, the container table doesn't even have a primary key. It has a foreign key that points back to the containing object. Plus an index for the sequence containers. Another approach that you can consider is to define a unique composite index (using the ODB index pragma). This will be semantically equivalent to the primary key. Boris From boris at codesynthesis.com Wed Jan 29 10:59:27 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 29 10:57:24 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: References: Message-ID: Hi Adrien, Adrien G writes: > Once that said, imagine you have a db with hundred of tables, its > insane to code it by hand, for time and human errors reasons Yes, that's the motivation. But what happens if/when the schema changes? Do you regenerate the classes? Or update them manually? In other words, is this feature going to generate classes that are the "rough draft" and the user can fill them in with customization or are they only for "data access" (i.e., don't have anything other than accessors and modifiers)? The problem with the "rough draft" approach is what happens when the schema changes and re-generating the classes will loose those customizations? The problem with the "data access" approach is that there is no logic in the classes. Then, another question is: in what form the database schema is passed to ODB? It can be an .sql file that ODB has to parse (quite complex). Alternatively, ODB (or, more likely, a separate tool) can query the database programmatically for the schema (easier but potentially less convenient). > Do you have a roadmap for this feature? Essentially, we are waiting for someone who has a good use-case and needs this feature badly enough as to help flesh out the details (such as the questions above) and then commit to start using the early implementation. > Is there any other c++ lib which supports this ? No, not that I am aware of. Boris From boris at codesynthesis.com Wed Jan 29 11:06:41 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 29 11:04:40 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: <52E7B9CC.6020509@turnkeycorrections.com> References: <52E7B9CC.6020509@turnkeycorrections.com> Message-ID: Hi Andrew, Andrew Hoffmeyer writes: > I'm not bragging, but rather illustrating that it's not impossible, > or even difficult to do, if you have a little motivation and some > spare time. Not to detract from your achievement, but doing so to satisfy requirements of a single application (or even a single company) is a lot easier than to create a general-purpose implementation. For starters, you only need to support MySQL while we have 5 databases. You also probably have a fixed set of data types that you map to while we will have to make it customizable (Qt types, Boost types, etc). Then there is the naming convention that should be used in the generated code. Etc. etc. Boris From andy.hoffmeyer at turnkeycorrections.com Wed Jan 29 12:17:10 2014 From: andy.hoffmeyer at turnkeycorrections.com (Andrew Hoffmeyer) Date: Wed Jan 29 12:17:21 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: References: <52E7B9CC.6020509@turnkeycorrections.com> Message-ID: <52E93796.2020708@turnkeycorrections.com> Boris, All of your concerns are certainly valid, and I wasn't trying to suggest that an implementation for odb would be trivial. Supporting only MySQL for my purposes alone was far from trivial, and it's far from being a finished product, although it does everything I need it to do at the moment. Data types could be based on a standard set, and customized with a map file. Naming conventions are always a point of contention, and there is obviously no one-size-fits-all answer. I'd love to have an in-depth discussion about this, and start working on something tangible that would be of benefit to the odb community. Perhaps that would be a subject for a new thread of discussion on this list. On 1/29/2014 10:06 AM, Boris Kolpackov wrote: > Hi Andrew, > > Andrew Hoffmeyer writes: > >> I'm not bragging, but rather illustrating that it's not impossible, >> or even difficult to do, if you have a little motivation and some >> spare time. > Not to detract from your achievement, but doing so to satisfy > requirements of a single application (or even a single company) > is a lot easier than to create a general-purpose implementation. > For starters, you only need to support MySQL while we have 5 > databases. You also probably have a fixed set of data types > that you map to while we will have to make it customizable (Qt > types, Boost types, etc). Then there is the naming convention > that should be used in the generated code. Etc. etc. > > Boris -- Andrew Hoffmeyer Software Developer/Network Administrator Turnkey Corrections/Turnkey Software Solutions V: 715-386-5700 F: 715-386-9988 From adrien_chem at hotmail.com Wed Jan 29 12:40:27 2014 From: adrien_chem at hotmail.com (Adrien G) Date: Wed Jan 29 12:40:34 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: References: , Message-ID: Hi Boris, >But what happens if/when the > schema changes? Do you regenerate the classes? Or update > them manually? - I would say every time the db changes the user should launch a script to get the c++ classes up to date.- For user customizations why not use a private class member embedded within the class generated which contains all the requirement to get odb working. In this way it would be easier to detect user changes and keep the odb specifics proper...- Concerning the generation itself I dont have the skills to bring any idea.. :/- What about studying how hibernate manages this issue? Bye :) > Date: Wed, 29 Jan 2014 17:59:27 +0200 > From: boris@codesynthesis.com > To: adrien_chem@hotmail.com > CC: odb-users@codesynthesis.com > Subject: Re: [odb-users] Generate C++ classes from a DB > > Hi Adrien, > > Adrien G writes: > > > Once that said, imagine you have a db with hundred of tables, its > > insane to code it by hand, for time and human errors reasons > > Yes, that's the motivation. But what happens if/when the > schema changes? Do you regenerate the classes? Or update > them manually? > > In other words, is this feature going to generate classes > that are the "rough draft" and the user can fill them in > with customization or are they only for "data access" > (i.e., don't have anything other than accessors and > modifiers)? > > The problem with the "rough draft" approach is what > happens when the schema changes and re-generating > the classes will loose those customizations? > > The problem with the "data access" approach is that > there is no logic in the classes. > > Then, another question is: in what form the database > schema is passed to ODB? It can be an .sql file that > ODB has to parse (quite complex). Alternatively, ODB > (or, more likely, a separate tool) can query the > database programmatically for the schema (easier but > potentially less convenient). > > > > Do you have a roadmap for this feature? > > Essentially, we are waiting for someone who has a good use-case and > needs this feature badly enough as to help flesh out the details > (such as the questions above) and then commit to start using the > early implementation. > > > > Is there any other c++ lib which supports this ? > > No, not that I am aware of. > > Boris From simon.gutierrez.brida at gmail.com Wed Jan 29 13:13:21 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Wed Jan 29 13:13:29 2014 Subject: [odb-users] XML type for a class member using ODB and postgresql In-Reply-To: References: Message-ID: Hi, 2014-01-29 Boris Kolpackov > Hi, > > Sim?n Emmanuel Guti?rrez Brida writes: > > > #pragma db type("XML") > > std::string data; > > > > But when I compile with odb I get > > > > error: unknown PostgreSQL type 'XML' > > In ODB database types like PG XML are called "extended database types" > and are no mapped automatically (there are too many such types and > different applications often require different mappings). > > Instead, what ODB does is provide a generic mechanism that allows > you to map any extended database type to any C++ type via one of > the "core database types" that are natively supported by ODB. This > article describes this mechanism in detail: > > > http://www.codesynthesis.com/~boris/blog/2012/07/18/custom-database-to-cxx-type-mapping-in-odb/ > > In your case, you can use TEXT as the core type and the mapping > expression could look something like this (based on the PG docs, > I haven't tested it myself): > > #pragma db map type("XML") \ > as("TEXT") \ > to("XMLPARSE(DOCUMENT (?))") \ > from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") > > Let us know if this works for you. > > Boris > Using #pragma db map type("XML") \ as("TEXT") \ to("XMLPARSE(DOCUMENT (?))") \ from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") #pragma db type("XML") std::string data; Appears to have solved the issue. From simon.gutierrez.brida at gmail.com Wed Jan 29 15:20:05 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Wed Jan 29 15:20:13 2014 Subject: [odb-users] deleting entries on relation table Message-ID: Hi, I have two classes User with these members #pragma db id std::string id; #pragma db value_not_null std::vector > patterns; Pattern with these members #pragma db id std::string id; #pragma db map type("XML") \ as("TEXT") \ to("XMLPARSE(DOCUMENT (?))") \ from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") #pragma db type("XML") std::string data; And I get a table for each class plus a table that relates a User with a Pattern. Now I want to delete a pattern but in order to do that I have to delete all entries in the relationship table that have the pattern id in the pattern column. Unfortunately there's no delete example using a one-to-many relation and the manual is not very helpful in this case, could someone help me with this? Thanks. From simon.gutierrez.brida at gmail.com Wed Jan 29 19:03:33 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Wed Jan 29 19:03:40 2014 Subject: [odb-users] querying with relationships Message-ID: Hi again, I have the following classes User with #pragma db id std::string id; #pragma db value_not_null std::vector > patterns; Pattern with #pragma db id std::string id; #pragma db map type("XML") \ as("TEXT") \ to("XMLPARSE(DOCUMENT (?))") \ from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") #pragma db type("XML") std::string data; Category pattern_category; (it's an enum) After compiling with odb I got 3 tables (User, Pattern and User_patterns) I want to do a query like, get all patterns p from user such that user.id== user_id and p.category == cattegory. Again I fail to find any information about how to do this in the manual or the examples. Any help will be appreciated From boris at codesynthesis.com Thu Jan 30 00:08:21 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 30 00:06:17 2014 Subject: [odb-users] deleting entries on relation table In-Reply-To: References: Message-ID: Hi Sim?n Emmanuel, Sim?n Emmanuel Guti?rrez Brida writes: > User with these members > > #pragma db id > std::string id; > > #pragma db value_not_null > std::vector > patterns; > > Pattern with these members > > #pragma db id > std::string id; > > #pragma db map type("XML") \ > as("TEXT") \ > to("XMLPARSE(DOCUMENT (?))") \ > from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") > #pragma db type("XML") > std::string data; > > And I get a table for each class plus a table that relates a User with a > Pattern. Generally, you can refer to related objects in queries one level deep (see the end of the introduction to Chapter 6, "Relationships"). Though note that there is no support for using containers in queries yet. In this light, it actually makes sense to change your relationship a bit. Firstly, we make it bi-directional so that we can refer to both objects whether you are querying for User or Pattern. Secondly, it makes sense to move the direct (non-inverse) pointer to Pattern since then you get rid of the linking table (note that here I assume you have the one(User)-to-many(Pattern) relationship, and not many-to- many). So now we have: User: #pragma db value_not_null inverse(user) std::vector > patterns; Pattern: #pragma db not_null std::tr1::weak_ptr user; You can change the shared/weak arrangement around. And also don't forget to use the session since it is a bi-directional (recursive) relationship. Once this is done, we can clean up the User table like this: db.erase_query (odb::query::user->id == 123); Also let me mention an alternative approach that will be available in the next release of ODB. There will be support for the ON DELETE clause which can be used to automatically clean up referencing objects. This feature is already implemented and you can test it (or start using it) in a pre-release, if you would like. Boris From boris at codesynthesis.com Thu Jan 30 00:12:27 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 30 00:10:22 2014 Subject: [odb-users] querying with relationships In-Reply-To: References: Message-ID: Hi Sim?n Emmanuel, Sim?n Emmanuel Guti?rrez Brida writes: > I want to do a query like, get all patterns p from user such that > user.id== user_id and p.category == cattegory. Given the changes to your relationship that I suggested in my previous reply[1], here is how we can do this: typedef odb::query CategoryQuery; db.query (CategoryQuery::user->id == user_id && CategoryQuery::category == category); [1] http://codesynthesis.com/pipermail/odb-users/2014-January/001758.html Boris From simon.gutierrez.brida at gmail.com Thu Jan 30 14:35:46 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Thu Jan 30 14:35:53 2014 Subject: [odb-users] querying with relationships In-Reply-To: References: Message-ID: Thanks, this should work. I was going to make something like you suggested in [1] but I didn't think it was necessary. After trying the code, I have this problems: if I declare the user field of Pattern like this #pragma db not_null std::tr1::weak_ptr user; Then I have an already persistent when I do persist(user); persist(pattern); if I declare the user field of Pattern like this #pragma db not_null std::tr1::shared_ptr user; I have no persist problems but now when I make a query to retrieve all users and store them in a vector the push_back hangs in a odb load method 2014-01-30 Boris Kolpackov > Hi Sim?n Emmanuel, > > Sim?n Emmanuel Guti?rrez Brida writes: > > > I want to do a query like, get all patterns p from user such that > > user.id== user_id and p.category == cattegory. > > Given the changes to your relationship that I suggested in my previous > reply[1], here is how we can do this: > > typedef odb::query CategoryQuery; > > db.query (CategoryQuery::user->id == user_id && > CategoryQuery::category == category); > > [1] http://codesynthesis.com/pipermail/odb-users/2014-January/001758.html > > Boris > From simon.gutierrez.brida at gmail.com Thu Jan 30 15:49:22 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Thu Jan 30 15:49:30 2014 Subject: [odb-users] session required inside a function with a session Message-ID: I have From simon.gutierrez.brida at gmail.com Thu Jan 30 15:58:29 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Thu Jan 30 15:58:36 2014 Subject: [odb-users] Re: session required inside a function with a session In-Reply-To: References: Message-ID: Sorry, I pressed enter by accident I have 1. vector Driver::retriveUsers() { 2. session s; 3. vector users(0); 4. transaction t (db->begin ()); 5. 6. user_result r (db->query (true)); 7. 8. for (user_result::iterator i (r.begin ()); i != r.end (); ++i) { 9. User* user = new User(*i); 10. users.push_back(*user); 11. } 12. 13. t.commit (); 14. return users; 15. } At line 9 I get a session required exception. I just want to have two classes an User and a Pattern, User have an id and a vector of weak_ptr defined as #pragma db value_not_null inverse(user) std::vector> patterns; and Pattern is defined as #pragma db id std::string id; #pragma db map type("XML") \ as("TEXT") \ to("XMLPARSE(DOCUMENT (?))") \ from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") #pragma db type("XML") std::string data; Category pattern_category; //an enum #pragma db not_null std::tr1::shared_ptr user; 2014-01-30 Sim?n Emmanuel Guti?rrez Brida > I have > From simon.gutierrez.brida at gmail.com Thu Jan 30 17:24:44 2014 From: simon.gutierrez.brida at gmail.com (=?ISO-8859-1?Q?Sim=F3n_Emmanuel_Guti=E9rrez_Brida?=) Date: Thu Jan 30 17:24:52 2014 Subject: [odb-users] deleting entries on relation table In-Reply-To: References: Message-ID: This won't work in the case were the same pattern is owned by two users, that's because when you try to persist the second case the pattern is already persisted so an exception is thrown. The problem I present can't be solved with just two tables Users and Patterns 2014-01-30 Boris Kolpackov > Hi Sim?n Emmanuel, > > Sim?n Emmanuel Guti?rrez Brida writes: > > > User with these members > > > > #pragma db id > > std::string id; > > > > #pragma db value_not_null > > std::vector > patterns; > > > > Pattern with these members > > > > #pragma db id > > std::string id; > > > > #pragma db map type("XML") \ > > as("TEXT") \ > > to("XMLPARSE(DOCUMENT (?))") \ > > from("XMLSERIALIZE(DOCUMENT (?) AS TEXT)") > > #pragma db type("XML") > > std::string data; > > > > And I get a table for each class plus a table that relates a User with a > > Pattern. > > Generally, you can refer to related objects in queries one level deep > (see the end of the introduction to Chapter 6, "Relationships"). Though > note that there is no support for using containers in queries yet. > > In this light, it actually makes sense to change your relationship > a bit. Firstly, we make it bi-directional so that we can refer to > both objects whether you are querying for User or Pattern. Secondly, > it makes sense to move the direct (non-inverse) pointer to Pattern > since then you get rid of the linking table (note that here I assume > you have the one(User)-to-many(Pattern) relationship, and not many-to- > many). > > So now we have: > > User: > > #pragma db value_not_null inverse(user) > std::vector > patterns; > > Pattern: > > #pragma db not_null > std::tr1::weak_ptr user; > > You can change the shared/weak arrangement around. And also don't > forget to use the session since it is a bi-directional (recursive) > relationship. > > Once this is done, we can clean up the User table like this: > > db.erase_query (odb::query::user->id == 123); > > Also let me mention an alternative approach that will be available > in the next release of ODB. There will be support for the ON DELETE > clause which can be used to automatically clean up referencing > objects. This feature is already implemented and you can test it > (or start using it) in a pre-release, if you would like. > > Boris > From sachnk at gmail.com Thu Jan 30 14:41:18 2014 From: sachnk at gmail.com (Sachin Kumar) Date: Thu Jan 30 22:13:22 2014 Subject: [odb-users] Prologue Order Message-ID: Greetings, I'm using ODB v2.3.0 64-bit with Visual Studio 2013. My application uses precompiled headers, which means I must include the precompiled header at the beginning of each cxx file. The --cxx-prologue option would ideally solve this. However, the prologue isn't the true prologue as it seems ODB is including first, and then user defined prologues. What's puzzling is that this behavior is different than XSD v3.3. The --cxx-prologue option with XSD 3.3 works as expected (i.e. it's really the prologue). Is there a workaround for this? Thanks, Sachin Kumar From boris at codesynthesis.com Thu Jan 30 22:26:39 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 30 22:24:36 2014 Subject: [odb-users] Re: session required inside a function with a session In-Reply-To: References: Message-ID: Hi Sim?n Emmanuel, Sim?n Emmanuel Guti?rrez Brida writes: > At line 9 I get a session required exception. Have you enabled session support for the User and Pattern classes? Citing Chapter 11, "Session": "Session support is optional and can be enabled or disabled on the per object basis using the db session pragma [...] We can also enable or disable session support for a group of objects at the namespace level [...] Finally, we can pass the --generate-session ODB compiler option to enable session support by default. With this option session support will be enabled for all the persistent classes except those for which it was explicitly disabled using the db session." > 1. vector Driver::retriveUsers() { > 2. session s; > 3. vector users(0); > 4. transaction t (db->begin ()); > 5. > 6. user_result r (db->query (true)); > 7. > 8. for (user_result::iterator i (r.begin ()); i != r.end (); ++i) { > 9. User* user = new User(*i); > 10. users.push_back(*user); This is a very round-about and inefficient way of doing it. Instead, you could simply do: users.push_back(*i); But, seeing that you have relationships, a much better version would be to use shared_ptr: vector > users; users.push_back(i.load ()); Boris From boris at codesynthesis.com Thu Jan 30 22:37:21 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 30 22:35:17 2014 Subject: [odb-users] deleting entries on relation table In-Reply-To: References: Message-ID: Hi Sim?n Emmanuel, Sim?n Emmanuel Guti?rrez Brida writes: > This won't work in the case were the same pattern is owned by two users, > that's because when you try to persist the second case the pattern is > already persisted so an exception is thrown. > > The problem I present can't be solved with just two tables Users and > Patterns Ok, so you have a many-to-many relationship and not a one-to-many. To make persist work in this case you need to first see (e.g., with a query) if a pattern with these properties already exists. If that's the case, then you just use the existing pattern instead of creating and persisting a new one. For completeness let me also address your original question: deleting related User objects when you delete a Pattern from the database in case of a many-to-many relationship. The two options are: Either use the on_delete pragma to make the database do this automatically for you (coming in 2.4.0 but is already available in a pre-release). Or use query support for containers, once it is implemented (no ETA for this feature at the moment). Boris From boris at codesynthesis.com Thu Jan 30 22:53:11 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 30 22:51:09 2014 Subject: [odb-users] querying with relationships In-Reply-To: References: Message-ID: Hi Sim?n Emmanuel, Sim?n Emmanuel Guti?rrez Brida writes: > if I declare the user field of Pattern like this > > #pragma db not_null > std::tr1::weak_ptr user; > > Then I have an already persistent when I do > > persist(user); > persist(pattern); > > if I declare the user field of Pattern like this > > #pragma db not_null > std::tr1::shared_ptr user; > > I have no persist problems Hm, I am not sure what's going on here. If anything, I would expect it to behave the other way around. Try to figure out which one of these persist() calls is throwing and then see if the object with such id actually already exists in the database. > but now when I make a query to retrieve all users and store them > in a vector the push_back hangs in a odb load method That would most likely be due to the lack of session. Boris From boris at codesynthesis.com Thu Jan 30 23:17:41 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 30 23:15:40 2014 Subject: [odb-users] Prologue Order In-Reply-To: References: Message-ID: Hi Sachin, Sachin Kumar writes: > My application uses precompiled headers, which means I must include > the precompiled header at the beginning of each cxx file. > > The --cxx-prologue option would ideally solve this. However, the prologue > isn't the true prologue as it seems ODB is including first, > and then user defined prologues. Yes, I see the problem. I can't think of a reason why we must have prologues/epilogues inside pre/post so I am going to change this for the next release. > Is there a workaround for this? Unfortunately, the only workaround is to temporarily (until the next version of ODB) disable precompiled headers for generated files. Alternatively, I can build you a pre-release binary of the ODB compiler with the fix. Boris From boris at codesynthesis.com Fri Jan 31 00:11:34 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 31 00:09:31 2014 Subject: [odb-users] Automatic generation of C++ classes from database schema Message-ID: Hi All, There seems to be quite a bit of interest in being able to automatically generate C++ classes from the database schema. However, this is a fairly "hairy" feature in the sense that there are a lot of unclear/complex aspects that need to be better understood. This is especially so since we are trying to design a general tool. The goal of this thread is to try and flesh-out an overall design for this feature based on experience and use-cases. So if you have some ideas or a need for this functionality, feel free to chime in. I've been thinking about this on and off for a couple of years now and here is an initial list of things that I believe we need to consider/discuss. Note also that not all of these features/ideas will be implemented in the first version (or even ever). However, it is a good idea to think through them to a certain level in order to understand how everything fits (or will fit) together. * What is the input to this tool? It can be an .sql file (dump from the database or manually created/maintained). Or it could be programmatically retrieved from a running database instance. The .sql approach feels cleanest to me but the complexity of parsing SQL is probably too much (don't believe me? check the Oracle SQL reference ;-)). The programmatic approach is probably the most practical even though it has a number of serious drawbacks (like the need to connect to a running database). Also, most likely it will be a separate tool that connects to the database and extracts the schema since we cannot link the ODB compiler to every database API library. So we need some kind of an intermediate format that the tool can produce and the ODB compiler can read. The XML format that we already have for the schema evolution sounds like a good candidate. Other things to consider in this area: - A way to limit the list of tables considered. - Do we use the ODB runtimes to access databases or should we just use the C APIs? Runtimes are not that convenient for manual database access though we could probably improve that. Also, for cases where we need to run plain SQL queries (as opposed to a special-purpose C API), we could even use ODB (views, etc). - We could make the ODB compiler call the extraction tool automatically and pipe the output to it. * What is the output of the tool? - File per class? File per schema? Something in-between. For large schemas, the file-per-schema approach is not going to scale, especially when the database support code generated by ODB is concerned. The file per class approach can also get unwieldy very quickly for a large number of classes. We have the same problem in XSD (may end up with a couple of thousand source files). It is manageable but not pretty. The in-between solution is to somehow allow the user to specify how to group classes into files (e.g., all related classes in a single file). * Intended uses: "rough draft" or "data access". What happens if/when the schema changes? Does the user re-generate the classes or update them manually? In other words, is this feature going to generate classes that are the "rough draft" and the user can fill them in with customizations (e.g., functions) or are they only for "data access" (i.e., don't have anything other than accessors and modifiers)? The problem with the "rough draft" approach is what happens when the schema changes and re-generating the classes will loose those customizations? The problem with the "data access" approach is that no functionality/logic can be added to the generated classes. We will probably have to support both use-cases. * Support for customization? There are some options for supporting the customization of the generated classes though none of them are particularly elegant. We could also consider doing the unspeakable and extract user customizations from the C++ header files. The only reason why I am even bringing this option up is because we are C++-parsing this file anyway (during the database support code generation). The user will still have to mark the regions (e.g., with pragmas which ODB could pre-insert for each class) so it could be brittle (if you make your changes in the wrong place, they will be gone). Though there doesn't seem to be anything better. * Basic types mapping (string, containers, smart pointers) Different users will want different basic types to be used in their generated classes (std::string, QString, etc). In a sense, this is a reverse mapping of what ODB currently does: C++ type to database type. What we need is a database type to C++ type mapping. The big question is how and where it is specified. It would also be nice if this somehow tied up to profiles. That is, if a user specified -p qt, then ODB will use Qt types (QString, Qt smart pointers, Qt containers, etc) in the generated C++ classes automatically. * Mapping for relationships, containers, (polymorphic) inheritance. This one is hard. ODB would somehow need to recognize certain patterns and map them to relationships, containers, etc. It may also need user guidance (see mapping customization/annotations). Generally, there are a lot more ways to structure these things (relationships, containers, inheritance) in relational databases than in C++ so for more esoteric cases there might not even be a sensible mapping. What would be nice is to come up with a general mechanism that would allow the user to specify the mapping for such cases. The big problem, of course, is that it can become so complex (see Hibernate and their relationship mapping) as to be completely unusable. An alternative could be to only support the straightforward cases and map the rest to plain objects for the user to deal with (i.e., one will be able to access the data but working with it won't be very convenient). * Mapping customization/annotations. Where and how is it specified? Things that the user may want to specify: - which tables to map - how to map tables (container, poly-inheritance, etc) - column type mapping * Naming convention used in the generated classes. We have licked this problem nicely in XSD. The idea is to use a set of regex patterns to transform names to conform to a specific naming convention. XSD comes with a set of predefined patterns (K&R, Camel Case, and Java). The user can "adjust" one of these with a few regex'es of their own or can create a completely custom naming convention. We should most likely just use the same mechanism since it seems to work great. Probably should also make spacing/indentation adjustable, especially if the user is expected to add their code to the generated files (see customization). From boris at codesynthesis.com Fri Jan 31 00:14:37 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 31 00:12:33 2014 Subject: [odb-users] Generate C++ classes from a DB In-Reply-To: <52E93796.2020708@turnkeycorrections.com> References: <52E7B9CC.6020509@turnkeycorrections.com> <52E93796.2020708@turnkeycorrections.com> Message-ID: Hi Andrew, Andrew Hoffmeyer writes: > I'd love to have an in-depth discussion about this, and start > working on something tangible that would be of benefit to the > odb community. Perhaps that would be a subject for a new thread > of discussion on this list. Sounds good. I've started the thread and would love to hear your (or anyone else's) thoughts: http://www.codesynthesis.com/pipermail/odb-users/2014-January/001769.html Boris From shantanu at kde.org Fri Jan 31 04:57:20 2014 From: shantanu at kde.org (Shantanu Tushar Jha) Date: Fri Jan 31 22:58:04 2014 Subject: [odb-users] Problem compiling applications when Qt is built without STL compatibility Message-ID: [Please Reply-to-all, I am not subscribed] Hi, We are using ODB for Plasma Media Center[1] in the KDE project. With the Qt supplied by (at least) Ubuntu and Fedora packages, STL compatibility is not on by default and hence we get this error when we compile our application- const class QString' has no member named 'toStdString' Follwing advice from a stackoverflow post[2], we have come up with a patch[3] for libodb-qt which seems to work. Now, for packaging we can either request distros to manually apply this patch to ODB packages, or is it possible for this to be applied upstream? [1] https://projects.kde.org/projects/extragear/multimedia/plasma-mediacenter/repository/show?rev=shantanu-sinny-media-caching [2] http://stackoverflow.com/questions/15806452/qt-error-const-class-qstring-has-no-member-named-tostdstring [3] http://quickgit.kde.org/?p=plasma-mediacenter.git&a=blob&h=7dbcc46c99939b2b8e3bf82f95e79312f79e306e&hb=b47baa36017311193d51f147373991b6c0c35c84&f=odb.patch Thanks, -- Shantanu Tushar (UTC +0530) http://www.shantanutushar.com