From dpbowe at hotmail.com Thu Feb 2 11:55:58 2017 From: dpbowe at hotmail.com (david bowe) Date: Thu Feb 2 14:30:31 2017 Subject: [odb-users] query_one on postgres Message-ID: Hi there, I'm new to odb but I'm trying to upgrade my code with it to add an extra bit of flexibility. I'm using Postgres (9.2.18) with odb (2.3.0), but the compiler is telling me that odb::database has no member query_one. See below driver.cxx:71:13: error: 'std::auto_ptr::element_type' has no member named 'query_one' db->query_one (query::code Could anybody provide any guidance on this issue as I have not been able to find anything on it so far Thanks, David From boris at codesynthesis.com Fri Feb 3 03:51:55 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Feb 3 03:52:04 2017 Subject: [odb-users] query_one on postgres In-Reply-To: References: Message-ID: Hi David, david bowe writes: > I'm using Postgres (9.2.18) with odb (2.3.0), but the compiler is > telling me that odb::database has no member query_one. That's because query_one() was added in ODB 2.4.0. See the NEWS file in the ODB compiler package for details. Boris From dpbowe at hotmail.com Fri Feb 3 03:53:56 2017 From: dpbowe at hotmail.com (david bowe) Date: Fri Feb 3 08:56:28 2017 Subject: [odb-users] query_one on postgres In-Reply-To: References: , Message-ID: Just realised that after I sent message Thanks for the reply > On 3 Feb 2017, at 08:52, Boris Kolpackov wrote: > > Hi David, > > david bowe writes: > >> I'm using Postgres (9.2.18) with odb (2.3.0), but the compiler is >> telling me that odb::database has no member query_one. > > That's because query_one() was added in ODB 2.4.0. See the NEWS file > in the ODB compiler package for details. > > Boris From dpbowe at hotmail.com Fri Feb 3 06:35:37 2017 From: dpbowe at hotmail.com (david bowe) Date: Fri Feb 3 08:56:28 2017 Subject: [odb-users] query_one on postgres In-Reply-To: References: , Message-ID: Hi Boris, I found this question posted on the users group about a year ago: http://www.codesynthesis.com/pipermail/odb-users/2016-February/003123.html I am receiving a similar error when I run query_one: driver: /usr/include/odb/result.txx:20: typename odb::object_traits::pointer_type odb::result::one() [with T = restaurants; typename odb::object_traits::pointer_type = restaurants*]: Assertion `++i == end ()' failed. Could you please advise me on the issue? Also, since I'm already asking, with the #pragma db id auto unsigned long id_; Should this automatically create public accessor functions or have I misinterpreted the docs? Thanks, David ________________________________ From: Boris Kolpackov Sent: 03 February 2017 08:51 To: david bowe Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] query_one on postgres Hi David, david bowe writes: > I'm using Postgres (9.2.18) with odb (2.3.0), but the compiler is > telling me that odb::database has no member query_one. That's because query_one() was added in ODB 2.4.0. See the NEWS file in the ODB compiler package for details. Boris From xzhan156 at ford.com Fri Feb 3 09:56:27 2017 From: xzhan156 at ford.com (Zhang, Xiaoguang (X.)) Date: Fri Feb 3 11:46:17 2017 Subject: [odb-users] A question about odb view Message-ID: Hi, This is Jack Zhang. I am from Ford Motor NA. I discovered odb when I searched ORM software. I used it in my application which is part of our interval utilities. It worked very well and I like it very much. Recently when I started using view and I found the view I created is not working for me. I hope you can point me out where is the miscoding or something else missing. I am using SQLite of odb. I created a file like: #ifndef __APPS_HXX__ #define __APPS_HXX__ #include #include #include #pragma db object class apps { public: apps(const int appid, std::string &desc) : appid_(appid), desc_(desc) {} const int appid () { return appid_; } const std::string & desc () const { return desc_; } void appid (int aid ) { appid_ = aid; } void desc (const std::string & d) { desc_ = d; } private: friend class odb::access; apps () {} #pragma db id auto unsigned long id_; #pragma db unique int appid_; std::string desc_; }; #pragma db view object(apps) struct apps_count { #pragma db column ("count(" + apps::appid_ + ")") std::size_t count; }; #endif And this is the way I use it: typedef odb::query cquery; typedef odb::result cresult; apps_count ac(odb_hdlr->query_value (cquery::appid == 1)); cout << "apps record number: " << ac.count << endl; if (!ac.count) { cout << "There is no record for table ID: " << myedit_appids[i].id << ", creating one now ..." << endl; //string s(myedit_appids[i].desc); apps a(myedit_appids[i].id, (std::string &)myedit_appids[i].desc); //apps a(myedit_appids[i].id, s); odb_hdlr->persist(a); } NOTE: Record with appid 1 is in database. Everything ac.count got zero back. Odb_hdlr gets initialized like this, and it is successfully created without error and exceptions: int c = 3; char *v[4]; v[0] = strdup("myedit"); v[1] = strdup("--database"); v[2] = strdup(adacs_dbname); v[3] = NULL; odb_hdlr = new odb::sqlite::database (c, v, false, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); Thanks in advance. Looking forward for your answer! Jack From boris at codesynthesis.com Mon Feb 6 07:17:26 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 6 07:17:35 2017 Subject: [odb-users] query_one on postgres In-Reply-To: References: Message-ID: Hi David, david bowe writes: > driver: /usr/include/odb/result.txx:20: > typename odb::object_traits::pointer_type odb::result::one() > [with T = restaurants; typename odb::object_traits::pointer_type = > restaurants*]: Assertion `++i == end ()' failed. Are you certain the query returns a single row? > Also, since I'm already asking, with the #pragma db id auto unsigned > long id_; Should this automatically create public accessor functions > or have I misinterpreted the docs? Yes, you have. ODB does not provide such functionality (since it has nothing to do with ORM). Boris From boris at codesynthesis.com Mon Feb 6 07:25:25 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 6 07:25:34 2017 Subject: [odb-users] A question about odb view In-Reply-To: References: Message-ID: Hi, Zhang, Xiaoguang (X.) writes: > Recently when I started using view and I found the view I created is > not working for me. I hope you can point me out where is the miscoding > or something else missing. I don't see anything immediately obvious in your code. The hello example that comes with ODB has a similar view and it is known to work so you may want to try that. Alternatively, if you believe this is a bug in ODB, I will need a minimal but complete test that reproduces the problem. Boris From marco.craveiro at gmail.com Mon Feb 6 11:19:22 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Tue Feb 7 11:38:17 2017 Subject: [odb-users] Using odb with oracle: stored procedures and cursors Message-ID: Hi odb-users, Many thanks for a fantastic product. I am about to embark on a project using ODB against an Oracle database, so I've started reading the documentation. However, I could not find any references to stored procedures or cursors in the Oracle section of the manual - although I can see it for SQL Server and others. I also quickly googled the mailinglist and grepped the source without success, so I thought I'd ask. Having said that, I must confess it wasn't the most thorough of searches - so I apologise in advance if I missed something obvious. My questions are: 1. Is it possible at present to call stored procedures for Oracle? 2. Is it possible for stored procedures from Oracle to return multiple cursors? 3. If one of both of these features are not currently available, would this require a lot of changes on the ODB side? I would consider submitting a patch if the work is straightforward. Also, I would consider gluing some hand-crafted code if required in order to get this to work, provided it is straightforward - for example, call the proc manually via the low-level ODB oracle API, obtain the cursors and then supply each cursor to ODB generated code. Many thanks for your time. -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key From boris at codesynthesis.com Tue Feb 7 12:14:43 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 7 12:14:53 2017 Subject: [odb-users] Using odb with oracle: stored procedures and cursors In-Reply-To: References: Message-ID: Hi Marco, Marco Craveiro writes: > Many thanks for a fantastic product. Thanks, I am glad you like it. > However, I could not find any references to stored procedures or > cursors in the Oracle section of the manual - although I can see > it for SQL Server and others. Right, we test/add support for stored procedures based on demand. > 1. Is it possible at present to call stored procedures for Oracle? We haven't got a test for it yet but it could already be working if Oracle returns the result in a way similar to a SELECT query (and all indications point to this being the case). If so, then calling a procedure would require a view along these lines: #pragma db view query("CALL my_stored_procedure(?)") struct my_stored_procedure { ... }; And then: using query = odb::query; db.query (query::_val (123) + "," + query::_val ("abc")); I could whip up a test if you are interested. > 2. Is it possible for stored procedures from Oracle to return multiple > cursors? You mean multiple result sets (e.g., sets of rows from multiple, potentially different, SELECT statements)? If so, that would most likely require extra, potentially non-trivial, support. > 3. If one of both of these features are not currently available, would > this require a lot of changes on the ODB side? It's hard to say without further investigation, but achieving anything with OCI (which is what libodb-oracle uses) is never straightforward. Boris From dpbowe at hotmail.com Thu Feb 9 05:53:45 2017 From: dpbowe at hotmail.com (david bowe) Date: Thu Feb 9 11:35:31 2017 Subject: [odb-users] Defining one-to-many bidirectional relationship Message-ID: Hi there, I have been trying to define a one to many relationship with the attached code. However, when defining the relationship pointers I get the below error asking me to define a database type. I can do this and the code will compile but it creates a relationship through a supplier_order table which is not what I need. I need each order to reference one suppler database.hxx:111:46: error: unable to map C++ type '::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >::this_type' used in data member 'orders_' to a PostgreSQL database type database.hxx:111:46: info: use '#pragma db value_type' to specify the database type Could anybody help me with what I am doing wrong? Thanks, David -------------- next part -------------- // database.hxx // #ifndef DATABASE_HXX #define DATABASE_HXX #include #include #include #include #include #include // Forward declaration class order; #pragma db object table("suppliers") class supplier { public: typedef ::order orders_type; supplier (const std::string& title, const std::string& phone, const std::string& address_line_1, const std::string& address_line_2, const std::string& address_line_3, const std::string& address_line_4, const std::string& address_line_5) : title_ (title), phone_ (phone), address_line_1_ (address_line_1), address_line_2_ (address_line_2), address_line_3_ (address_line_3), address_line_4_ (address_line_4), address_line_5_ (address_line_5) {} unsigned long id() const { return id_; } const std::string& title() const { return title_; } const std::string& phone() const { return phone_; } const std::string& address_line_1() const { return address_line_1_; } const std::string& address_line_2() const { return address_line_2_; } const std::string& address_line_3() const { return address_line_3_; } const std::string& address_line_4() const { return address_line_4_; } const std::string& address_line_5() const { return address_line_5_; } void title(const std::string& title) { title_ = title; } void phone(const std::string& phone) { phone_ = phone; } void address_line_1(const std::string& address_line_1) { address_line_1_ = address_line_1; } void address_line_2(const std::string& address_line_2) { address_line_2_ = address_line_2; } void address_line_3(const std::string& address_line_3) { address_line_3_ = address_line_3; } void address_line_4(const std::string& address_line_4) { address_line_4_ = address_line_4; } void address_line_5(const std::string& address_line_5) { address_line_5_ = address_line_5; } private: friend class odb::access; supplier() {} #pragma db id auto unsigned long id_; #pragma db type("VARCHAR(255)") column("title") std::string title_; #pragma db type("VARCHAR(255)") column("phone") null std::string phone_; #pragma db type("VARCHAR(255)") column("address_line_1") std::string address_line_1_; #pragma db type("VARCHAR(255)") column("address_line_2") null std::string address_line_2_; #pragma db type("VARCHAR(255)") column("address_line_3") null std::string address_line_3_; #pragma db type("VARCHAR(255)") column("address_line_4") null std::string address_line_4_; #pragma db type("VARCHAR(255)") column("address_line_5") null std::string address_line_5_; #pragma db type("TIMESTAMP") column("created_at") options("DEFAULT CURRENT_TIMESTAMP") boost::posix_time::ptime created_; #pragma db type("TIMESTAMP") column("updated_at") options("DEFAULT CURRENT_TIMESTAMP") boost::posix_time::ptime updated_; #pragma db value_not_null inverse(supplier_) std::vector > orders_; }; #pragma db object table("orders") class order { public: typedef ::supplier supplier_type; order (boost::shared_ptr supplier, std::string bd_code) : supplier_ (supplier), bd_code_ (bd_code) {} unsigned long id() const { return id_; } const std::string& bd_code() const { return bd_code_; } void bd_code(const std::string& bd_code) { bd_code_ = bd_code; } public: // Belongs to: supplier const boost::shared_ptr& supplier() const { return supplier_; } void supplier(const boost::shared_ptr& supplier) { supplier_ = supplier; } private: friend class odb::access; order() {} #pragma db id auto unsigned long id_; #pragma db not_null type("VARCHAR(255)") column("code") std::string bd_code_; #pragma db type("TIMESTAMP") column("created_at") options("DEFAULT CURRENT_TIMESTAMP") boost::posix_time::ptime created_; #pragma db type("TIMESTAMP") column("updated_at") options("DEFAULT CURRENT_TIMESTAMP") boost::posix_time::ptime updated_; #pragma db not_null boost::shared_ptr supplier_; }; #endif // DATABASE_HXX From marco.craveiro at gmail.com Fri Feb 10 03:50:00 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Fri Feb 10 03:50:13 2017 Subject: [odb-users] Using odb with oracle: stored procedures and cursors In-Reply-To: References: Message-ID: Hi Boris, thanks for the prompt reply. > We haven't got a test for it yet but it could already be working if > Oracle returns the result in a way similar to a SELECT query (and > all indications point to this being the case). If so, then calling > a procedure would require a view along these lines: > > #pragma db view query("CALL my_stored_procedure(?)") > struct my_stored_procedure > { > ... > }; > > And then: > > using query = odb::query; > > db.query (query::_val (123) + "," + > query::_val ("abc")); > > I could whip up a test if you are interested. actually don't worry just yet - I changed the code to select the table directly and that is working quite well. If we end up having to use procs, I will use this to update the code and test it and give you guys feedback. > You mean multiple result sets (e.g., sets of rows from multiple, > potentially different, SELECT statements)? If so, that would most > likely require extra, potentially non-trivial, support. Yes, unfortunately that is exactly what the procs are currently doing! However, I will try to bypass these procs altogether as they don't seem to fit the ODB/ORM model. Cheers -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key From marco.craveiro at gmail.com Fri Feb 10 03:59:37 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Fri Feb 10 03:59:51 2017 Subject: [odb-users] Using prefetch with Oracle Message-ID: Hi odb-users, I have managed to do a successful test using ODB against an Oracle database, and the ORM mapping part is working quite well. However, the one snag I have is that fetching at the moment is a tad slow. It was pointed out that I needed to enable prefetching in the Oracle drivers so I've been investigating how to go about it. I can't see any direct mentions in the manual; I saw references to bulk loading for updates/deletes/inserts but not selects. However, I think I'm missing something as I found this comment[1]: > For fetches network traffic can be minimized using pre-fetching. ODB enables > this feature if the underlying database supports it (e.g., Oracle). This is exactly what I am looking for. But I grepped the code and found no references to OCI_ATTR_PREFETCH_ROWS[2], so I tried manually hacking "execute" as follows (statement.cxx in odb-oracle): const int prefetchSize(5000); sword r = OCIAttrSet (stmt_, OCI_HTYPE_STMT, (void*)&prefetchSize, sizeof(int), OCI_ATTR_PREFETCH_ROWS, err); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) translate_error (err, r); Largely copied from SO[3]. This did not crash :-) but it didn't make any performance difference either. So in conclusion, any ideas on how to enable prefetching / bulk loading for Oracle, using ODB? If this is not presently supported, how should one extend the code to support it? Cheers -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key [1] https://www.reddit.com/r/cpp/comments/p4hiq/odb_c_orm_180_released_adds_support_for_sql/ [2] https://docs.oracle.com/cd/B13789_01/appdev.101/b10779/oci04sql.htm [3] http://stackoverflow.com/questions/26301386/call-ocistmtexecute-with-ref-cursor-and-oci-attr-prefetch-rows From dpbowe at hotmail.com Fri Feb 10 03:45:59 2017 From: dpbowe at hotmail.com (david bowe) Date: Fri Feb 10 06:01:46 2017 Subject: [odb-users] Defining one-to-many bidirectional relationship In-Reply-To: References: , Message-ID: Thanks for the reply Micheal, Although, I'm not quite sure I understand. Do you mean that I should only use a reference pointer on one side of the database map? I want to be able to query up and down through the relationship as necessary. David ________________________________ From: Michael Sent: 09 February 2017 17:29 To: david bowe Subject: Re: [odb-users] Defining one-to-many bidirectional relationship On February 9, 2017 5:53:45 AM EST, david bowe wrote: >Hi there, > > >I have been trying to define a one to many relationship with the >attached code. However, when defining the relationship pointers I get >the below error asking me to define a database type. I can do this and >the code will compile but it creates a relationship through a >supplier_order table which is not what I need. I need each order to >reference one suppler That's not typically how best to normalize this kind of object to database mapping. Doesn't matter if we're talking about odb/C++ or NHibernate/C#. What you described is more of a domain layer and/or business logic concern IMPO. In this case the * on the order to supply side is 1, but the mapping can be the same. HTH >database.hxx:111:46: error: unable to map C++ type >'::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >::this_type' >used in data member 'orders_' to a PostgreSQL database type > >database.hxx:111:46: info: use '#pragma db value_type' to specify the >database type > > >Could anybody help me with what I am doing wrong? > > >Thanks, > > >David -- Sent from my Android device with K-9 Mail. Please excuse my brevity. From dpbowe at hotmail.com Fri Feb 10 10:07:18 2017 From: dpbowe at hotmail.com (david bowe) Date: Fri Feb 10 10:38:06 2017 Subject: [odb-users] Defining one-to-many bidirectional relationship In-Reply-To: References: , , Message-ID: Thanks Micheal, I am creating a simple database schema so I will remove the inverse pointer. I think I misunderstood what is required for the relationship to be bidirectional (sorry still pretty new to this). When I compile the code now it creates the correct schema (below), however, the supplier foreign key in the orders table does not show a reference to the suppliers table. Any ideas why this might be? The use of boost pointers maybe?? Sorry to keep asking David CREATE TABLE "suppliers" ( "id" BIGSERIAL NOT NULL PRIMARY KEY, "title" VARCHAR(255) NOT NULL, "phone" VARCHAR(255) NULL, "address_line_1" VARCHAR(255) NOT NULL, "address_line_2" VARCHAR(255) NULL, "address_line_3" VARCHAR(255) NULL, "address_line_4" VARCHAR(255) NULL, "address_line_5" VARCHAR(255) NULL, "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP); CREATE TABLE "orders" ( "id" BIGSERIAL NOT NULL PRIMARY KEY, "code" VARCHAR(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "supplier_id" BIGINT NOT NULL); ________________________________ From: Michael Sent: 10 February 2017 14:48 To: david bowe Subject: Re: [odb-users] Defining one-to-many bidirectional relationship On February 10, 2017 3:45:59 AM EST, david bowe wrote: >Thanks for the reply Micheal, > > >Although, I'm not quite sure I understand. Do you mean that I should >only use a reference pointer on one side of the database map? I want to >be able to query up and down through the relationship as necessary. I am not as familiar with the odb side of things as I am ORM, per se. AFAIK, *-* would support that, yes, with specific restrictions being domain concerns. All I can encourage is just to think it through. Perhaps develop a couple of domain-only test cases to exercise the hypotheses. HTH >David > >________________________________ >From: Michael >Sent: 09 February 2017 17:29 >To: david bowe >Subject: Re: [odb-users] Defining one-to-many bidirectional >relationship > > > >On February 9, 2017 5:53:45 AM EST, david bowe >wrote: >>Hi there, >> >> >>I have been trying to define a one to many relationship with the >>attached code. However, when defining the relationship pointers I get >>the below error asking me to define a database type. I can do this and >>the code will compile but it creates a relationship through a >>supplier_order table which is not what I need. I need each order to >>reference one suppler > >That's not typically how best to normalize this kind of object to >database mapping. Doesn't matter if we're talking about odb/C++ or >NHibernate/C#. What you described is more of a domain layer and/or >business logic concern IMPO. > >In this case the * on the order to supply side is 1, but the mapping >can be the same. > >HTH > >>database.hxx:111:46: error: unable to map C++ type >>'::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >>::this_type' >>used in data member 'orders_' to a PostgreSQL database type >> >>database.hxx:111:46: info: use '#pragma db value_type' to specify the >>database type >> >> >>Could anybody help me with what I am doing wrong? >> >> >>Thanks, >> >> >>David > >-- >Sent from my Android device with K-9 Mail. Please excuse my brevity. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. From boris at codesynthesis.com Fri Feb 10 10:45:20 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Feb 10 10:45:30 2017 Subject: [odb-users] Defining one-to-many bidirectional relationship In-Reply-To: References: Message-ID: Hi David, david bowe writes: > database.hxx:111:46: error: unable to map C++ type > '::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >::this_type' > used in data member 'orders_' to a PostgreSQL database type You are using Boost smart pointers. Have you enabled the Boost profile (libodb-boost)? Boris From boris at codesynthesis.com Fri Feb 10 11:07:35 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Feb 10 11:07:44 2017 Subject: [odb-users] Using prefetch with Oracle In-Reply-To: References: Message-ID: Hi Marco, Marco Craveiro writes: > This is exactly what I am looking for. But I grepped the code and > found no references to OCI_ATTR_PREFETCH_ROWS[2], so I tried manually > hacking "execute" as follows (statement.cxx in odb-oracle): > > const int prefetchSize(5000); > sword r = OCIAttrSet (stmt_, > OCI_HTYPE_STMT, > (void*)&prefetchSize, > sizeof(int), > OCI_ATTR_PREFETCH_ROWS, > err); > > if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) > translate_error (err, r); > > Largely copied from SO[3]. This did not crash :-) but it didn't make > any performance difference either. Just to confirm, did you hack select_statement::execute()? Boris From dpbowe at hotmail.com Fri Feb 10 11:33:00 2017 From: dpbowe at hotmail.com (david bowe) Date: Sun Feb 12 07:25:14 2017 Subject: [odb-users] Defining one-to-many bidirectional relationship In-Reply-To: References: , Message-ID: Hi Boris, I have downloaded the libodb-boost profile and compiled it from source. Do i need to add any further options to the compiler or includes in the header file? Thanks ________________________________ From: Boris Kolpackov Sent: 10 February 2017 15:45 To: david bowe Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Defining one-to-many bidirectional relationship Hi David, david bowe writes: > database.hxx:111:46: error: unable to map C++ type > '::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >::this_type' > used in data member 'orders_' to a PostgreSQL database type You are using Boost smart pointers. Have you enabled the Boost profile (libodb-boost)? Boris From dpbowe at hotmail.com Fri Feb 10 11:51:33 2017 From: dpbowe at hotmail.com (david bowe) Date: Sun Feb 12 07:25:14 2017 Subject: [odb-users] Defining one-to-many bidirectional relationship In-Reply-To: References: , Message-ID: Ok just saw in the docs that an option has to be added $ odb -d pgsql --profile boost --generate-schema --generate-query database.hxx ________________________________ From: Boris Kolpackov Sent: 10 February 2017 15:45 To: david bowe Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Defining one-to-many bidirectional relationship Hi David, david bowe writes: > database.hxx:111:46: error: unable to map C++ type > '::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >::this_type' > used in data member 'orders_' to a PostgreSQL database type You are using Boost smart pointers. Have you enabled the Boost profile (libodb-boost)? Boris From marco.craveiro at gmail.com Mon Feb 13 05:25:38 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Mon Feb 13 05:25:52 2017 Subject: [odb-users] Using prefetch with Oracle In-Reply-To: References: Message-ID: Boris, > Just to confirm, did you hack select_statement::execute()? Aha! I must have changed it in the wrong place! :-) I re-did my change as I had reverted it but this time I made sure it was on select_statement::execute(); I can now see a massive difference in performance (~5x faster cold). Quick hack attached. I'm going to have a look and see if I can follow the same pattern for the bulk parameter so that it uses the pragma value when setting the prefetch (and does nothing if bulk is not set). If I do this, would you accept it as a patch? Cheers -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key -------------- next part -------------- A non-text attachment was scrubbed... Name: prefetch.patch Type: text/x-patch Size: 1194 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20170213/63f637f3/prefetch.bin From anaswara.nn at gmail.com Mon Feb 13 06:05:48 2017 From: anaswara.nn at gmail.com (Anaswara Nair) Date: Mon Feb 13 06:06:00 2017 Subject: [odb-users] Store JSON value to DB Message-ID: Is there any method other than by converting it to wstring to store a JSON value as such to SQLite database using ODB? From boris at codesynthesis.com Mon Feb 13 08:36:53 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 13 08:37:02 2017 Subject: [odb-users] Store JSON value to DB In-Reply-To: References: Message-ID: Hi, Anaswara Nair writes: > Is there any method other than by converting it to wstring to store a JSON > value as such to SQLite database using ODB? SQLite just added the json1 loadable extension[1]. While it still stores the data as TEXT (as discussed in the documentation, due to backwards compatibility that's the only way), it provides some functions that can be useful. If I were to use this extension with ODB I would probably map an extended database type[2] so that I get automatic validation and minification on INSERT/UPDATE: #pragma db map type("JSON_TEXT") as("TEXT") to("json((?))") #pragma db object struct object { #pragma db type("JSON_TEXT") std::string json; }; And then use the other functions json1 provides in ODB views if I wanted to extract only some parts of the JSON document. [1] https://sqlite.org/json1.html [2] http://www.codesynthesis.com/~boris/blog/2012/07/18/custom-database-to-cxx-type-mapping-in-odb/ Boris From boris at codesynthesis.com Mon Feb 13 08:56:52 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 13 08:57:02 2017 Subject: [odb-users] Using prefetch with Oracle In-Reply-To: References: Message-ID: <20170213135652.GA22900@codesynthesis.com> Hi Marco, Marco Craveiro writes: > I'm going to have a look and see if I can follow the same pattern for > the bulk parameter so that it uses the pragma value when setting the > prefetch (and does nothing if bulk is not set). If I do this, would > you accept it as a patch? Hm, I am not sure the bulk approach (with a compiler-time pragma) is right in this case. There we don't really have a choice since we need to know the "batch buffer" size. But here it is all runtime. Plus, you may want to have different prefetch for different queries of the same object. In fact, you can already customize it for queries (but not for object loads) by using prepared queries (Section 4.5 in the manual): 1. Create prepared query. 2. Get its statement (statement()). 3. Cast it to odb::oracle::select_statement. 4. Call handle() on the result to get OCIStmt*. 5. Set custom OCI_ATTR_PREFETCH_ROWS. 6. Execute the query. The problems with this approach are: (1) it is tedious and (2) it doesn't work for non-query SELECT's (e.g., database::load()). So perhaps the way to do it is: 1. Provide prefetch() functions on oracle::database() and oracle::connection() that can be used to modify database-wide and connection-wide prefetch values. Also set it to some reasonable default (say 512?) 2. Provide oracle::select_statement::prefetch() to make the prepared query approach less tedious. What do you think? Boris From marco.craveiro at gmail.com Mon Feb 13 09:00:03 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Mon Feb 13 09:00:17 2017 Subject: [odb-users] Using prefetch with Oracle In-Reply-To: <20170213135652.GA22900@codesynthesis.com> References: <20170213135652.GA22900@codesynthesis.com> Message-ID: Hi Boris, > Hm, I am not sure the bulk approach (with a compiler-time pragma) is > right in this case. There we don't really have a choice since we need > to know the "batch buffer" size. > > But here it is all runtime. Plus, you may want to have different > prefetch for different queries of the same object. In fact, you > can already customize it for queries (but not for object loads) > by using prepared queries (Section 4.5 in the manual): > > 1. Create prepared query. > > 2. Get its statement (statement()). > > 3. Cast it to odb::oracle::select_statement. > > 4. Call handle() on the result to get OCIStmt*. > > 5. Set custom OCI_ATTR_PREFETCH_ROWS. > > 6. Execute the query. > > The problems with this approach are: (1) it is tedious and (2) it > doesn't work for non-query SELECT's (e.g., database::load()). So > perhaps the way to do it is: > > 1. Provide prefetch() functions on oracle::database() and > oracle::connection() that can be used to modify database-wide > and connection-wide prefetch values. Also set it to some > reasonable default (say 512?) > > 2. Provide oracle::select_statement::prefetch() to make the > prepared query approach less tedious. > > What do you think? Yep, makes perfect sense. Let me have a go at coding this then. Cheers -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key From dpbowe at hotmail.com Tue Feb 14 12:18:17 2017 From: dpbowe at hotmail.com (david bowe) Date: Wed Feb 15 03:58:25 2017 Subject: [odb-users] Defining database with multiple table mapping files Message-ID: Hi there, In the given examples all object classes are defined within one file. However, with a number of tables making up my database and want to define each in a separate header file for maintainability. Is there a best practice for doing this in terms of compilation? At the moment I can either paste all headers into one file and pass it to the odb compiler, or try to compile each individually and include each into my database driver file. Could anybody advise what is best? Thanks, David From boris at codesynthesis.com Wed Feb 15 11:10:28 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 15 11:10:38 2017 Subject: [odb-users] Defining database with multiple table mapping files In-Reply-To: References: Message-ID: Hi David, david bowe writes: > At the moment I can either paste all headers into one file and pass > it to the odb compiler, or try to compile each individually and > include each into my database driver file. Individual compilation/inclusion is definitely the recommended approach. And if you need to generate a single .sql file, then you can use the --at-once ODB compiler option. Boris From xiang.zhao at gamegou.com Thu Feb 16 02:51:15 2017 From: xiang.zhao at gamegou.com (=?utf-8?B?WmhhbyBYaWFuZw==?=) Date: Thu Feb 16 11:32:31 2017 Subject: [odb-users] Atomic and batch update in ODB Message-ID: Dear ODB Developers: I've been using ODB and MySQL for quite some time, It's been very useful for my projects, and I think it would be much more helpful if the following features could be included in odb: a) Atomic Update Considering the following code from http://www.codesynthesis.com/products/odb/doc/manual.xhtml#3.5: void update_age (database& db, person& p) { try { transaction t (db.begin ()); p.age (p.age () + 1); db.update (p); t.commit (); } catch (...) { transaction t (db.begin ()); db.load (p.id (), p); t.commit (); throw; } } If this function is called in two threads at the same time, it could result in only one age in added. Is there any plan for feature that equivalent to the following SQL: update `person` set `age` = `age` + 1 where `id` = xxx; ? b) Batch Update For now I can do a query and update the results in a for-loop, but it would be much slower than a single update statement like: update `person` set `age` = `age` + 1 where `first_name` = 'Joe'; Or: update `person` set `age`= case `id` when 1 then 10 when 2 then 20 else `id` where id in (1, 2); c) Batch Insert Similar the previous one, it would be helpful to have something like this: insert into `person` (`id`, `age`) values (1, 10), (2, 20); d) Insert and duplicate This feature can be implemented with find() and insert() now, however it would be atomic and faster with something like this: insert into `person` (`id`, `age`) values (1, 10) on duplicate key ignore; Or: insert into `person` (`id`, `age`) values (1, 10) on duplicate key update set `age` = values(`age`) Or in some case: insert into `person` (`id`, `age`) values (1, 10) on duplicate key update set `age` += values(`age`) I hope my suggestions could be taken into consideration in your further development plan. Thanks Zhao Xiang From dpbowe at hotmail.com Thu Feb 16 04:10:48 2017 From: dpbowe at hotmail.com (david bowe) Date: Thu Feb 16 11:32:31 2017 Subject: [odb-users] Defining database with multiple table mapping files In-Reply-To: References: , Message-ID: Thanks Boris, This is great. So I can just include the the everthing-odb.cxx file generated by --at-once into my driver? Also I appreciate that this isn't really an odb question, but how should I set the make file target for the odb compiler since it generates multiple output files? Thanks, David ________________________________ From: Boris Kolpackov Sent: 15 February 2017 16:10 To: david bowe Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Defining database with multiple table mapping files Hi David, david bowe writes: > At the moment I can either paste all headers into one file and pass > it to the odb compiler, or try to compile each individually and > include each into my database driver file. Individual compilation/inclusion is definitely the recommended approach. And if you need to generate a single .sql file, then you can use the --at-once ODB compiler option. Boris From dpbowe at hotmail.com Thu Feb 16 05:09:58 2017 From: dpbowe at hotmail.com (david bowe) Date: Thu Feb 16 11:32:31 2017 Subject: [odb-users] Defining database with multiple table mapping files In-Reply-To: References: , , Message-ID: Ok sorry stupid question, I have this sorted now ________________________________ From: david bowe Sent: 16 February 2017 09:10 To: odb-users@codesynthesis.com Subject: Re: [odb-users] Defining database with multiple table mapping files Thanks Boris, This is great. So I can just include the the everthing-odb.cxx file generated by --at-once into my driver? Also I appreciate that this isn't really an odb question, but how should I set the make file target for the odb compiler since it generates multiple output files? Thanks, David ________________________________ From: Boris Kolpackov Sent: 15 February 2017 16:10 To: david bowe Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Defining database with multiple table mapping files Hi David, david bowe writes: > At the moment I can either paste all headers into one file and pass > it to the odb compiler, or try to compile each individually and > include each into my database driver file. Individual compilation/inclusion is definitely the recommended approach. And if you need to generate a single .sql file, then you can use the --at-once ODB compiler option. Boris From boris at codesynthesis.com Thu Feb 16 11:50:25 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 16 11:50:35 2017 Subject: [odb-users] Atomic and batch update in ODB In-Reply-To: References: Message-ID: Hi Zhao, Yes, we have this feature on our TODO list (we call it "mass update" not to be confused with "batch update" as found in Oracle/SQL Server). I've added a note about your email to this item. In the meantime, you can probably implement some/most of this using optimistic concurrency (to achieve atomicity) and/or native statements. Thanks, Boris From harriev9 at gmail.com Sun Feb 19 07:06:45 2017 From: harriev9 at gmail.com (harriev9) Date: Sun Feb 19 07:07:19 2017 Subject: [odb-users] Compile libodb-qt Message-ID: <1487506005.6682.5.camel@gmail.com> Hi, I have working on compiling libodb-qt on a fedora 25 installation. I had trouble with running ./configure. It complaint about not finding QtCore. First I added the -fPIC option, but this did not help: ./configure CXXFLAGS=-fPIC There was another problem. Qt uses #include in its headers and so also /usr/include/qt5 was needed in the include path. At the end i found out that i had to use: ./configure CXXFLAGS=-fPIC??CPPFLAGS=-I/usr/include/qt5 LDFLAGS=- L/usr/lib64/ Is this the correct way to solve the problem? From boris at codesynthesis.com Mon Feb 20 12:23:37 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 20 12:23:46 2017 Subject: [odb-users] Compile libodb-qt In-Reply-To: <1487506005.6682.5.camel@gmail.com> References: <1487506005.6682.5.camel@gmail.com> Message-ID: Hi, harriev9 writes: > First I added the -fPIC option, but this did not help: > > ./configure CXXFLAGS=-fPIC Yes, Qt now required that. We will look into adding this automatically for the next release. > There was another problem. Qt uses #include in its > headers and so also /usr/include/qt5 was needed in the include path. This path should be tried automatically. > At the end i found out that i had to use: > > ./configure CXXFLAGS=-fPIC CPPFLAGS=-I/usr/include/qt5 LDFLAGS=- > L/usr/lib64/ > > Is this the correct way to solve the problem? That depends on what the problem was. Can you look into config.log to see which tests were tried and why they are failing? Boris From gilles.benepougoue at gmail.com Mon Feb 20 18:53:51 2017 From: gilles.benepougoue at gmail.com (Gilles Bene) Date: Mon Feb 20 18:54:04 2017 Subject: [odb-users] Compilation error when calling QLazyWeakPointer::load() Message-ID: Hi . Problem, when calling the load() methode of a QLazyWeakPointer please need help. I have a class with a member as a QLazyWeakPointer example: class SomeClass { //... QLazyWeakPointer bill_; //.... } qreal Bill::getAmount() const{ return bill_.load()->Amount(); } When I compile I get this error message. /usr/include/odb/qt/smart-ptr/lazy-ptr.ixx: In instantiation of 'QSharedPointer QLazyWeakPointer::load() const [with T = Sortie]': Facture.cpp:28:18: required from here /usr/include/odb/qt/smart-ptr/lazy-ptr.ixx:473:7: error: no match for 'operator=' (operand types are 'QSharedPointer' and 'odb::object_traits::pointer_type {aka Sortie*}') r = i_.template load (false); // Keep id. ^ I get the same error anytime I call the load() methode of a QLazyWeakPointer ( ) Please help. From boris at codesynthesis.com Tue Feb 21 11:49:22 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 21 11:49:30 2017 Subject: [odb-users] Compilation error when calling QLazyWeakPointer::load() In-Reply-To: References: Message-ID: Hi Gilles, Gilles Bene writes: > /usr/include/odb/qt/smart-ptr/lazy-ptr.ixx:473:7: error: no match for > 'operator=' (operand types are 'QSharedPointer' and > 'odb::object_traits::pointer_type {aka Sortie*}') > r = i_.template load (false); // Keep id. > ^ Well, the compiler tells you exactly what the problem is: load() returns Sortie* and left-hand-side is QSharedPointer. And that assignment is not valid. Which one would be valid? For example, QSharedPointer to QSharedPointer. Why is load() returning Sortie* instead of QSharedPointer? Because you haven't told ODB that your object pointers should be something other than raw pointers (see Section 3.3, "Object and View Pointers" in the manual). Boris From gilles.benepougoue at gmail.com Wed Feb 22 13:45:55 2017 From: gilles.benepougoue at gmail.com (Gilles Bene) Date: Wed Feb 22 13:46:08 2017 Subject: [odb-users] Compilation error when calling QLazyWeakPointer::load() In-Reply-To: References: Message-ID: Hi, Thanks for your prompt reply. Actually I want load() to return QSharedPointer instead of Sortie*. I've' used the --default-pointer option to specify the default pointer for the whole file by suppliying it as ODB Compiler Command Line option in my make file. And I can see that the option is actually supplied to odb at compile time as I can see the output of make calling odb. odb -x -fPIC -x --std=c++11 --database pgsql --sql-name-case lower --profile qt --default-pointer QSharedPointer --hxx-prologue-file ../pointer-par-defaut.hxx --generate-query --generate-session -I/usr/include/x86_64-linux-gnu/qt5 Sortie.hxx the file pointer-par-defaut.hxx contains the line: #include But I still have the same error message. I've check the file Sortie-odb.hxx wether it actually include the definition of the default pointer. I notice that it actually has the include #include Here is a part of the file Sortie-odb.hxx: // This file was generated by ODB, object-relational mapping (ORM) // compiler for C++. // #ifndef SORTIE_ODB_HXX #define SORTIE_ODB_HXX // Begin prologue. // #include #if ODB_QT_VERSION != 2040000 // 2.4.0 # error ODB and C++ compilers see different libodb-qt interface versions #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // // End prologue. #include #if (ODB_VERSION != 20400UL) #error ODB runtime version mismatch #endif #include #include "Sortie.hxx" #include "../DocsRelances/Relancable-odb.hxx" #include "Relance-odb.hxx" #include "../Personnels/Personnel-odb.hxx" #include "Emballage-odb.hxx" #include "Fournisseur-odb.hxx" #include "HistPrix-odb.hxx" #include "PrixFourn-odb.hxx" #include "../Produits/Produit-odb.hxx" #include "Tonnage-odb.hxx" #include "DetailsSortie-odb.hxx" #include "Facture-odb.hxx" #include "Reglement-odb.hxx" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace odb { // Sortie // template <> struct class_traits< ::Sortie > { static const class_kind kind = class_object; }; template <> class access::object_traits< ::Sortie > { public: typedef ::Sortie object_type; typedef ::QSharedPointer< ::Sortie > pointer_type; typedef odb::pointer_traits pointer_traits; static const bool polymorphic = true; typedef ::Sortie root_type; typedef ::std::string discriminator_type; typedef polymorphic_map map_type; typedef polymorphic_concrete_info info_type; // ...... I tought the line typedef ::QSharedPointer< ::Sortie > pointer_type; Was the specifying the default pointer for all instances of Sortie. I looked for anything like odb::object_traits::pointer_type as appearing in the error message but couldn't fine. May be am getting something wrong. Please need your advice. Sorry for my lengthy message. On 21 February 2017 at 17:49, Boris Kolpackov wrote: > Hi Gilles, > > Gilles Bene writes: > > > /usr/include/odb/qt/smart-ptr/lazy-ptr.ixx:473:7: error: no match for > > 'operator=' (operand types are 'QSharedPointer' and > > 'odb::object_traits::pointer_type {aka Sortie*}') > > r = i_.template load (false); // Keep id. > > ^ > > Well, the compiler tells you exactly what the problem is: load() returns > Sortie* and left-hand-side is QSharedPointer. And that assignment > is not valid. Which one would be valid? For example, QSharedPointer > to QSharedPointer. Why is load() returning Sortie* instead of > QSharedPointer? Because you haven't told ODB that your object > pointers should be something other than raw pointers (see Section 3.3, > "Object and View Pointers" in the manual). > > Boris > > > -- Gilles BENE POUGOUE From dpbowe at hotmail.com Thu Feb 23 04:34:40 2017 From: dpbowe at hotmail.com (david bowe) Date: Thu Feb 23 11:27:42 2017 Subject: [odb-users] Custom tracer Message-ID: Hi there, I am implementing a custom tracer to log odb querys in a file using the given example in the manual. However, when adding the custom tracer through the db pointer I am told I am not able to access the tracer odb::tracer class. The compiler gives the following error. src/db-driver.cxx:68:21: error: ?odb::tracer? is an inaccessible base of ?pgsql_tracer? db->tracer (tracer); ^ Any help would be gratefully appreciated [?] The following is my database connection function void Database::connectDatabase() { const std::string username = "user"; const std::string password = "pass"; const std::string database = "database"; const std::string host = "localhost"; const unsigned int port = 5432; try { pgsql_tracer tracer; db.reset(new odb::pgsql::database (username, password, database, host, port)); db->tracer (tracer); } catch (odb::exception& e) { FILE_LOG(logERROR) << e.what(); exit(1); } } Thanks, David -------------- next part -------------- A non-text attachment was scrubbed... Name: =?utf-8?B?T3V0bG9va0Vtb2ppLfCfmKEucG5n?= Type: image/png Size: 461 bytes Desc: =?utf-8?B?T3V0bG9va0Vtb2ppLfCfmKEucG5n?= Url : http://codesynthesis.com/pipermail/odb-users/attachments/20170223/1769f95f/utf-8BT3V0bG9va0Vtb2ppLfCfmKEucG5n.png From boris at codesynthesis.com Thu Feb 23 11:54:23 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 23 11:54:33 2017 Subject: [odb-users] Compilation error when calling QLazyWeakPointer::load() In-Reply-To: References: Message-ID: Hi Gilles, Gilles Bene writes: > template <> > class access::object_traits< ::Sortie > > { > public: > typedef ::Sortie object_type; > typedef ::QSharedPointer< ::Sortie > pointer_type; Yes, this looks correct. > I looked for anything like odb::object_traits::pointer_type > as appearing in the error message but couldn't fine. Hm, do you have Sortie-odb.hxx included in the source file where you call load()? odb::object_traits (defined in ) derives from odb::access::object_traits. Boris From boris at codesynthesis.com Thu Feb 23 12:02:22 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 23 12:02:31 2017 Subject: [odb-users] Custom tracer In-Reply-To: References: Message-ID: Hi David david bowe writes: > I am implementing a custom tracer to log odb querys in a file using > the given example in the manual. > > However, when adding the custom tracer through the db pointer I am told > I am not able to access the tracer odb::tracer class. The compiler gives > the following error. > > src/db-driver.cxx:68:21: error: ?odb::tracer? is an inaccessible base > of ?pgsql_tracer? > > db->tracer (tracer); If only you read that section on tracers until the end, you would have had your answer. Quoting Section 3.13, "Tracing SQL Statement Execution": "Note also that you can only set a database-specific tracer object using a database-specific database instance, for example:" pgsql_tracer tracer; odb::database& db = ...; db.tracer (tracer); // Compile error. odb::pgsql::database& db = ...; db.tracer (tracer); // Ok. Boris From gilles.benepougoue at gmail.com Thu Feb 23 12:44:53 2017 From: gilles.benepougoue at gmail.com (Gilles Bene) Date: Thu Feb 23 12:45:07 2017 Subject: [odb-users] Compilation error when calling QLazyWeakPointer::load() In-Reply-To: References: Message-ID: Wouah , thanks a lot for your quality technical supply. I've included the file Sortie-odb.hxx Sortie-odb.hxx in the source file where I call load() and every thing is ok. Thanks once more. You have a fabulous peace of software. I've been using it for just a month and am loving it. On 23 February 2017 at 17:54, Boris Kolpackov wrote: > Hi Gilles, > > Gilles Bene writes: > > > template <> > > class access::object_traits< ::Sortie > > > { > > public: > > typedef ::Sortie object_type; > > typedef ::QSharedPointer< ::Sortie > pointer_type; > > Yes, this looks correct. > > > > I looked for anything like odb::object_traits::pointer_type > > as appearing in the error message but couldn't fine. > > Hm, do you have Sortie-odb.hxx included in the source file where you > call load()? odb::object_traits (defined in ) > derives from odb::access::object_traits. > > Boris > -- Gilles BENE POUGOUE From marco.craveiro at gmail.com Fri Feb 24 07:23:53 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Fri Feb 24 07:24:07 2017 Subject: [odb-users] Using prefetch with Oracle In-Reply-To: References: <20170213135652.GA22900@codesynthesis.com> Message-ID: Hi Boris, >> So perhaps the way to do it is: >> >> 1. Provide prefetch() functions on oracle::database() and >> oracle::connection() that can be used to modify database-wide >> and connection-wide prefetch values. Also set it to some >> reasonable default (say 512?) >> >> 2. Provide oracle::select_statement::prefetch() to make the >> prepared query approach less tedious. >> >> What do you think? > > Yep, makes perfect sense. Let me have a go at coding this then. Just a quick heads up, I am working on this but I ended up having to first replicate the setup at home so it's taking me quite a while. On the plus side I am cataloguing the adventure under a series of blog posts - [1], [2] so far - which may (or may not) help other Oracle / ODB users. Should be getting to the code soon, hopefully. Cheers -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key [1] Nerd Food: Northwind, or Using Dogen with ODB - Part I: http://mcraveiro.blogspot.co.uk/2017/02/nerd-food-northwind-or-using-dogen-with.html [2] Nerd Food: Northwind, or Using Dogen with ODB - Part II: http://mcraveiro.blogspot.co.uk/2017/02/nerd-food-northwind-or-using-dogen-with_24.html From harriev9 at gmail.com Sun Feb 26 10:49:42 2017 From: harriev9 at gmail.com (harriev9) Date: Sun Feb 26 10:49:57 2017 Subject: [odb-users] Compile libodb-qt In-Reply-To: References: <1487506005.6682.5.camel@gmail.com> Message-ID: <1488124182.14426.1.camel@gmail.com> Hi, I am sorry. I must have done something wrong since i cant reproduce the problem anymore. I have another problem however trying to compile my code. I constantly get an error: /usr/local/include/odb/qt/basic/pgsql/default-mapping.hxx:8:26: fatal error: QtCore/QString: No such file or directory I think the include files are correct, during configuration i logged the include directories: -- !=!=! dir='/usr/include/qt5' -- !=!=! dir='/usr/include/qt5/QtWidgets' -- !=!=! dir='/usr/include/qt5/QtGui' -- !=!=! dir='/usr/include/qt5/QtCore' -- !=!=! dir='/usr/lib64/qt5/./mkspecs/linux-g++' -- !=!=! dir='/usr/include' -- !=!=! dir='/usr/include/qt5' -- !=!=! dir='/usr/include/qt5/QtCore' -- !=!=! dir='/usr/lib64/qt5/./mkspecs/linux-g++' -- !=!=! dir='/usr/include/qt5' -- !=!=! dir='/usr/include/qt5/QtGui' -- !=!=! dir='/usr/include/qt5/QtCore' -- !=!=! dir='/usr/lib64/qt5/./mkspecs/linux-g++' -- !=!=! dir='/usr/include' -- !=!=! dir='/home/harrie/projects/OpenControl/Components/src' -- !=!=! dir='/home/harrie/projects/OpenControl/Components' -- !=!=! dir='/home/harrie/projects/OpenControl/Components/src' -- !=!=! What can be the problem here? Harrie On Mon, 2017-02-20 at 19:23 +0200, Boris Kolpackov wrote: > Hi, > > harriev9 writes: > > > First I added the -fPIC option, but this did not help: > > > > ./configure CXXFLAGS=-fPIC > > Yes, Qt now required that. We will look into adding this > automatically > for the next release. > > > > There was another problem. Qt uses #include in its > > headers and so also /usr/include/qt5 was needed in the include > > path. > > This path should be tried automatically. > > > > At the end i found out that i had to use: > > > > ./configure CXXFLAGS=-fPIC CPPFLAGS=-I/usr/include/qt5 LDFLAGS=- > > L/usr/lib64/ > > > > Is this the correct way to solve the problem? > > That depends on what the problem was. Can you look into config.log > to see which tests were tried and why they are failing? > > Boris From harriev9 at gmail.com Sun Feb 26 11:52:14 2017 From: harriev9 at gmail.com (harriev9) Date: Sun Feb 26 11:52:28 2017 Subject: [odb-users] [Fwd: Compile libodb-qt], Correction. Found the problem. References: <1487506005.6682.5.camel@gmail.com> Message-ID: <1488127934.14426.3.camel@gmail.com> Hi, I had a problem, the compiler complained QtCore/QString not found. I found, after a long search, that the odb compiler needs the include directories passed too. I use cmake. So i added: ?INCLUDE ${Qt5Core_INCLUDE_DIRS}? to: odb_compile(...) I also had to add? STANDARD c++11 since qt5 requires this. Cheers, Harrie -------------- next part -------------- An embedded message was scrubbed... From: harriev9 Subject: Compile libodb-qt Date: Sun, 19 Feb 2017 13:06:45 +0100 Size: 901 Url: http://codesynthesis.com/pipermail/odb-users/attachments/20170226/d2e41eb8/attachment.mht From marco.craveiro at gmail.com Sun Feb 26 18:03:25 2017 From: marco.craveiro at gmail.com (Marco Craveiro) Date: Sun Feb 26 18:03:38 2017 Subject: [odb-users] BLOBs and multi-database Message-ID: Hi odb-users, I am using ODB with multiple databases (PostgreSQL and Oracle). A couple of my fields is are BLOB/BYTEA. I have managed to map these successfully to each of the databases individually via the pragma type, but I don't seem to be able to map them to each database "simultaneously" when on multi-database scenario. I think my google-fu/documentation-fu is failing me badly - I am convinced I had seen a way to set the type on a per-database basis but for the life of me I just can't find that reference again. Cheers -- Marco Craveiro MD, Domain Driven Consulting about: http://about.me/marcocraveiro blog: http://mcraveiro.blogspot.co.uk twitter: https://twitter.com/MarcoCraveiro That the Ideas are themselves manifestations (of the Idea-Idea) and that the Idea-Idea is a-kind-of Manifestation-Idea?which is a-kind-of itself, so that the system is completely self-describing? would have been appreciated by Plato as an extremely practical joke [Plato]. -- Alan Key From boris at codesynthesis.com Mon Feb 27 07:04:21 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 27 07:04:29 2017 Subject: [odb-users] BLOBs and multi-database In-Reply-To: References: Message-ID: Hi Marco, Marco Craveiro writes: > [...] but I don't seem to be able to map them to each database > "simultaneously" when on multi-database scenario. You are probably looking for the database pragma prefix (introduction to Chapter 16, "Multi-Database Support"): #pragma db pgsql:type("BYTEA") oracle:type("BLOB") std::vector data; Boris From sean.clarke at sec-consulting.co.uk Tue Feb 28 15:49:11 2017 From: sean.clarke at sec-consulting.co.uk (Sean Clarke) Date: Tue Feb 28 15:49:24 2017 Subject: [odb-users] Inverse and composite Id Message-ID: Hi, I am having some problems trying to model a many-to-one relationship where one entity has a composite primary key (I think that is the issue). Trying to define what I am doing (this is a cut down definition - ignore any compilation errors, this is just to summarise): class A { #pragma db value struct Id { int a; int b; } #pragma db id Id m_id; #pragma db value_not_null std::shared_ptr m_b; }; class B { using id_t = std::uint32_t; #pragma db id id_t m_id; #pragma db inverse(m_b) std::vector> m_as; }; The error I get when I compile is along the lines of: //odb_gen/A-odb.hxx:385:70: error: ?image_type? in ?class odb::access::composite_value_traits? does not name a type composite_value_traits< ::B::Id, id_pgsql >::image_type value_value; ^~~~~~~~~~ Any hints on what I am doing wrong? Regards Sean Clarke