From boris at codesynthesis.com Mon Jun 1 03:43:44 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 1 03:43:54 2015 Subject: [odb-users] #pragma view pointer() ignored on Windows In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > I thought it would be a good idea to include the ??include?? folder > from odb-2.4.0 [...] Ok, I've added the following to the README. I guess these days you not only have to explain what to do but also what not to do (shaking my head): " Finally, note that the mingw\ sub-directory is internal ODB implementation details and you should not need to know anything about its existence. In particular, mingw\ contains the include\ sub-directory which in turn contains what looks like libodb headers. You must not add this include/ sub-directory to your C++ compiler include search path (you would be surprised how many people do this "for good measure" and end up with a broken build). " Boris From axel50397 at gmail.com Mon Jun 1 09:50:18 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Jun 1 09:50:43 2015 Subject: [odb-users] #pragma view pointer() ignored on Windows In-Reply-To: References: Message-ID: On 1 juin 2015 at 09:43:54, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Ok, I've added the following to the README. I guess these days you > not only have to explain what to do but also what not to do (shaking > my head) Aaaah... New dev these days are less thinking by themselves ?_? Anyway, thank you. -- Cordialement, Adnan RIHAN. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Mon Jun 1 09:54:17 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Jun 1 09:54:41 2015 Subject: [odb-users] "vector_base::_arm" redeclared without dllimport Message-ID: Hi there, I?m compiling a project from OS X to Windows. Don?t worry (Boris), it?s working now, but I have nearly 260 compiler warnings (GCC 4.9.1, 32 bit):? In file included from C:\msys\1.0\local\include/odb/vector-impl.hxx:218:0, [...] ? ? ? ? ? ? ? ? ?from C:\Documents and Settings\Max13\Bureau\LGC_src\apps\LGC\src\main.cpp:20: C:\msys\1.0\local\include/odb/vector-impl.ixx:194:15: warning: 'void odb::vector_base::_arm(odb::transaction&) const' redeclared without dllimport attribute after being referenced with dll linkage ? ?inline void vector_base:: ? ? ? ? ? ? ? ?^ Don?t know if it?s known, or specific to GCC or the given version. My app is however working normally, so this is just a feedback. Thanks for this work (ODB). -- Cordialement, Adnan RIHAN. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From boris at codesynthesis.com Mon Jun 1 13:44:52 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 1 13:45:01 2015 Subject: [odb-users] "vector_base::_arm" redeclared without dllimport In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > C:\msys\1.0\local\include/odb/vector-impl.ixx:194:15: warning: > 'void odb::vector_base::_arm(odb::transaction&) const' redeclared > without dllimport attribute after being referenced with dll linkage I've see those before as well but with the more recent GCC (4.9) and MinGW-W64, they are gone. In fact, with 2.4.0, our tests and examples build without any warnings. So I assume this was a GCC issue that got fixed. Note also that we use the --enable-auto-import option when building for MinGW. That is: ./configure ... LDFLAGS=-Wl,--enable-auto-import Boris From axel50397 at gmail.com Mon Jun 1 13:49:01 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Jun 1 13:49:26 2015 Subject: [odb-users] "vector_base::_arm" redeclared without dllimport In-Reply-To: References: Message-ID: I have added this LDFLAGS when compiling libodb, libodb-sqlite, libodb-qt. Ok, thanks for the reply. On 1 juin 2015 at 19:45:01, Boris Kolpackov (boris@codesynthesis.com) wrote: Hi Adnan, Adnan RIHAN writes: > C:\msys\1.0\local\include/odb/vector-impl.ixx:194:15: warning: > 'void odb::vector_base::_arm(odb::transaction&) const' redeclared > without dllimport attribute after being referenced with dll linkage I've see those before as well but with the more recent GCC (4.9) and MinGW-W64, they are gone. In fact, with 2.4.0, our tests and examples build without any warnings. So I assume this was a GCC issue that got fixed. Note also that we use the --enable-auto-import option when building for MinGW. That is: ./configure ... LDFLAGS=-Wl,--enable-auto-import Boris --? Cordialement, Adnan RIHAN. Directeur-G?rant de?Eolis-Software,?soci?t? de services informatiques. GPG:?5675-62BA (https://keybase.io/max13/key.asc) ->?Si vous?n'utilisez?pas GPG mais?souhaitez quand m?me m?envoyer un?e-mail chiffr?: (https://encrypt.to/0x567562BA). From boris at codesynthesis.com Mon Jun 1 13:56:31 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 1 13:56:42 2015 Subject: [odb-users] "vector_base::_arm" redeclared without dllimport In-Reply-To: References: Message-ID: Adnan, Adnan RIHAN writes: > I have added this LDFLAGS when compiling libodb, libodb-sqlite, libodb-qt. It is probably more important to add it when you are linking your application. Though, I must admit, I have no idea whether it has any effect on that warning. Boris From axel50397 at gmail.com Mon Jun 1 13:58:32 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Jun 1 13:58:56 2015 Subject: [odb-users] "vector_base::_arm" redeclared without dllimport In-Reply-To: References: Message-ID: I will try later with a more recent version of GCC. And I?ll try to add it when linking. I?ll keep you updated. On 1 juin 2015 at 19:56:41, Boris Kolpackov (boris@codesynthesis.com) wrote: Adnan, Adnan RIHAN writes: > I have added this LDFLAGS when compiling libodb, libodb-sqlite, libodb-qt. It is probably more important to add it when you are linking your application. Though, I must admit, I have no idea whether it has any effect on that warning. Boris --? Cordialement, Adnan RIHAN. Directeur-G?rant de?Eolis-Software,?soci?t? de services informatiques. GPG:?5675-62BA (https://keybase.io/max13/key.asc) ->?Si vous?n'utilisez?pas GPG mais?souhaitez quand m?me m?envoyer un?e-mail chiffr?: (https://encrypt.to/0x567562BA). From andrew at a-cunningham.com Mon Jun 1 17:41:10 2015 From: andrew at a-cunningham.com (Andrew Cunningham) Date: Tue Jun 2 04:23:01 2015 Subject: [odb-users] Performance and another question Message-ID: I am evaluating ODB as a replacement for an 'abandon-ware' commercial OODB. I have a question regarding performance that other ODB users might be able to help with If we were looking for the best performance when working with lots of data for a single user ( single process/multiple threads) on a Windows workstation what would you suggest as the best SQL DB option ( i.e. SQLIte vs MySQL vs. Postgres etc) Obviously I think that most people would suggest SQLite as you are writing ?in process? with no external communication to a server process. However, when working with our existing OODB vendor we got much suprisingly better performance from using a 'local' server vs. ?in-process? as the server process could perform disk operations without blocking the client process. The server client communication was over shared memory not network sockets when both were on a local machine. One more question: What would people recommend for modeling a ?graph? as a persistent data type in odb. I use boost::graph currently. I am trying to think of a way to do it in ODB is not too awfully slow/clumsy/messy. Just wondering if it has been done before. Andrew From axel50397 at gmail.com Tue Jun 2 04:56:53 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Tue Jun 2 04:57:18 2015 Subject: [odb-users] Performance and another question In-Reply-To: References: Message-ID: Hi Andrew, I?m not yet working with intensive tasks, so I can?t provide you my personal experience. However, I think the choice of a DB backend depends on what type of data you?re dealing with, their size, how often, concurrency and the usage of the project. For example, if you?re making a simple Cash register app (as I?m on, currently), you?re dealing with simple little values (short strings and integers), multiple time a day, no concurrency (except if you have multiple cashiers) and the DB expanding linearly with time. I think sqlite is the best for this kind of project, it?s light, portable, and can handle a huge quantity of data. So maybe, you will never have to care about the database. I can?t find another example for non in-process DB, but basically, if you need concurrency, caching, speed, huge complexity (constantly joining many many tables) and if you know the data will expand exponentially, then you?ll need a server. The server (apart from the ORM) is capable of expanding (Clustering/NAS/SAN/bigger disks), caching (if you?re joining a lot but accessing the same joins multiple times a day), and can be anywhere (accessed via network). These are few details I think about for the choice of a type of backend. Then, I look around for some benchmarks to see which would be the best for my architecture. Sqlite is in-process, MySQL is a server but can also be loaded as an embedded server (http://www.mysql.com/oem/), and so on. - SQLite, when to use: https://www.sqlite.org/whentouse.html - MySQL, known enough - MariaDB, comparison chart: https://mariadb.com/products/mariadb - And then you have the NoSQL databases (plus DB like Oracle, SQL Server, ...), but I?ve never worked with them. -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). On 2 juin 2015 at 10:23:32, Andrew Cunningham (andrew@a-cunningham.com) wrote: I am evaluating ODB as a replacement for an 'abandon-ware' commercial OODB.? I have a question regarding performance that other ODB users might be able? to help with? If we were looking for the best performance when working with lots of data? for a single user ( single process/multiple threads) on a Windows? workstation what would you suggest as the best SQL DB option ( i.e. SQLIte? vs MySQL vs. Postgres etc)? Obviously I think that most people would suggest SQLite as you are writing? ?in process? with no external communication to a server process. However,? when working with our existing OODB vendor we got much suprisingly better? performance from using a 'local' server vs. ?in-process? as the server? process could perform disk operations without blocking the client process.? The server client communication was over shared memory not network sockets? when both were on a local machine.? One more question: What would people recommend for modeling a ?graph? as a? persistent data type in odb. I use boost::graph currently. I am trying to? think of a way to do it in ODB is not too awfully slow/clumsy/messy. Just? wondering if it has been done before.? Andrew? From boris at codesynthesis.com Tue Jun 2 05:57:19 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 2 05:57:31 2015 Subject: [odb-users] Performance and another question In-Reply-To: References: Message-ID: Hi Andrew, Andrew Cunningham writes: > I am evaluating ODB as a replacement for an 'abandon-ware' commercial OODB. > > I have a question regarding performance that other ODB users might be able > to help with > > If we were looking for the best performance when working with lots of data > for a single user ( single process/multiple threads) on a Windows > workstation what would you suggest as the best SQL DB option ( i.e. SQLIte > vs MySQL vs. Postgres etc) > > Obviously I think that most people would suggest SQLite as you are writing > ?in process? with no external communication to a server process. However, > when working with our existing OODB vendor we got much suprisingly better > performance from using a 'local' server vs. ?in-process? as the server > process could perform disk operations without blocking the client process. > The server client communication was over shared memory not network sockets > when both were on a local machine. This is actually an interesting question. Firstly, if you have a single process/single thread setup then SQLite will beat everything else hands down, by a very large margin. Now, when we move to the multi-threaded case, things get tricky. SQLite multi-threading support is really poor, especially the "write" side of it. So if you have a lot of threads and they are write-heavy (in other words, the worst kind of scenario), then SQLite starts to suffer, badly. For example, we have the 'threads' test in odb-tests which is this kind, write-heavy torture test. PostgreSQL (and recent MySQL) absolutely smoke SQLite if the machine has a decent number of cores (say 8 or more). So this is the spectrum. And the answer to your question depends on where on this spectrum is your application. The best approach, of course, is to create a test that mimics your application's workload and see how each database performs. Luckily, with ODB, it will be very easy to write a simple test that you can run against every database. > One more question: What would people recommend for modeling a ?graph? as a > persistent data type in odb. I use boost::graph currently. I am trying to > think of a way to do it in ODB is not too awfully slow/clumsy/messy. Just > wondering if it has been done before. When mapping a C++ class to a database class in ODB, there are generally three ways to do it: 1. Map it to a corresponding database type (e.g., if your target database supported the graph data type or something similar). 2. Map it to some kind of a "database data structure", i.e., one or more columns and/or tables that capture the data in a suitable form. In your case, for example, this could mean having column(s) that contain containers (in PG) that represents the graph. Or, perhaps, it makes sense to map it as a container. See, for instance, how we mapped the Boost multi-index container in the libodb-boost profile. 3. Map it to an opaque data structure, i.e., a BLOB. In this case you simply store some binary representation of your data structure. Which way is best depends on your requirements. (1) is of course the cleanest but I don't think there are build-in graph types supported by the databases we are talking about. I guess, one way to approach is to ask yourself how would you persist your graphs in a text file. Then try to model this format using (2). I unfortunately not familiar enough with the way these two graph types store their internal representations so cannot really suggest which way is best. But if you can outline what would be a good "on disk" representation, I could suggest how to map it to the database. Boris From andrew at a-cunningham.com Tue Jun 2 11:35:02 2015 From: andrew at a-cunningham.com (Andrew Cunningham) Date: Wed Jun 3 12:02:21 2015 Subject: [odb-users] Performance and another question In-Reply-To: References: Message-ID: Hi Adnan, Thanks for your reply. I have CAE simulation data with over 200 separate C++ classes. So I have a complex object model and a LOT of data per model ( often 20 GB per 'model/file/database'). We are "single user" but will be running multiple threads during computation . Each thread typically reads from the database, with some limited writing from each thread. Obviously I will have to greatly simplify my 'object model' for the persistent classes. The reason ODB is so attractive is the ease with which we can make a class persistent and experiment. Andrew On Tue, Jun 2, 2015 at 1:56 AM, Adnan RIHAN wrote: > Hi Andrew, > > I?m not yet working with intensive tasks, so I can?t provide you my > personal experience. > > However, I think the choice of a DB backend depends on what type of data > you?re dealing with, their size, how often, concurrency and the usage of > the project. > > For example, if you?re making a simple Cash register app (as I?m on, > currently), you?re dealing with simple little values (short strings and > integers), multiple time a day, no concurrency (except if you have multiple > cashiers) and the DB expanding linearly with time. I think sqlite is the > best for this kind of project, it?s light, portable, and can handle a huge > quantity of data. So maybe, you will never have to care about the database. > > I can?t find another example for non in-process DB, but basically, if you > need concurrency, caching, speed, huge complexity (constantly joining many > many tables) and if you know the data will expand exponentially, then > you?ll need a server. The server (apart from the ORM) is capable of > expanding (Clustering/NAS/SAN/bigger disks), caching (if you?re joining a > lot but accessing the same joins multiple times a day), and can be anywhere > (accessed via network). > > These are few details I think about for the choice of a type of backend. > Then, I look around for some benchmarks to see which would be the best for > my architecture. Sqlite is in-process, MySQL is a server but can also be > loaded as an embedded server (http://www.mysql.com/oem/), and so on. > > - SQLite, when to use: https://www.sqlite.org/whentouse.html > - MySQL, known enough > - MariaDB, comparison chart: https://mariadb.com/products/mariadb > - And then you have the NoSQL databases (plus DB like Oracle, SQL Server, > ...), but I?ve never worked with them. > > -- > Cordialement, Adnan RIHAN. > Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. > > GPG: 5675-62BA (https://keybase.io/max13/key.asc) > -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un > e-mail chiffr?: (https://encrypt.to/0x567562BA). > > > > On 2 juin 2015 at 10:23:32, Andrew Cunningham (andrew@a-cunningham.com) > wrote: > I am evaluating ODB as a replacement for an 'abandon-ware' commercial > OODB. > > I have a question regarding performance that other ODB users might be able > to help with > > If we were looking for the best performance when working with lots of data > for a single user ( single process/multiple threads) on a Windows > workstation what would you suggest as the best SQL DB option ( i.e. SQLIte > vs MySQL vs. Postgres etc) > > Obviously I think that most people would suggest SQLite as you are writing > ?in process? with no external communication to a server process. However, > when working with our existing OODB vendor we got much suprisingly better > performance from using a 'local' server vs. ?in-process? as the server > process could perform disk operations without blocking the client process. > The server client communication was over shared memory not network sockets > when both were on a local machine. > > One more question: What would people recommend for modeling a ?graph? as a > persistent data type in odb. I use boost::graph currently. I am trying to > think of a way to do it in ODB is not too awfully slow/clumsy/messy. Just > wondering if it has been done before. > > Andrew > > > From andrew at a-cunningham.com Tue Jun 2 11:39:44 2015 From: andrew at a-cunningham.com (Andrew Cunningham) Date: Wed Jun 3 16:15:22 2015 Subject: [odb-users] Performance and another question In-Reply-To: References: Message-ID: Hi Boris, Thanks for the input. Boost::graph can use many representations ( vectors, lists, etc) as the basis of the data structure it uses for the graph itself - it's just a template class(es) passed in that have to meet the requirements. Let me think about this a bit.. Andrew On Tue, Jun 2, 2015 at 2:57 AM, Boris Kolpackov wrote: > Hi Andrew, > > Andrew Cunningham writes: > > > I am evaluating ODB as a replacement for an 'abandon-ware' commercial > OODB. > > > > I have a question regarding performance that other ODB users might be > able > > to help with > > > > If we were looking for the best performance when working with lots of > data > > for a single user ( single process/multiple threads) on a Windows > > workstation what would you suggest as the best SQL DB option ( i.e. > SQLIte > > vs MySQL vs. Postgres etc) > > > > Obviously I think that most people would suggest SQLite as you are > writing > > ?in process? with no external communication to a server process. However, > > when working with our existing OODB vendor we got much suprisingly better > > performance from using a 'local' server vs. ?in-process? as the server > > process could perform disk operations without blocking the client > process. > > The server client communication was over shared memory not network > sockets > > when both were on a local machine. > > This is actually an interesting question. Firstly, if you have a > single process/single thread setup then SQLite will beat everything > else hands down, by a very large margin. > > Now, when we move to the multi-threaded case, things get tricky. > SQLite multi-threading support is really poor, especially the > "write" side of it. So if you have a lot of threads and they are > write-heavy (in other words, the worst kind of scenario), then > SQLite starts to suffer, badly. For example, we have the 'threads' > test in odb-tests which is this kind, write-heavy torture test. > PostgreSQL (and recent MySQL) absolutely smoke SQLite if the > machine has a decent number of cores (say 8 or more). > > So this is the spectrum. And the answer to your question depends > on where on this spectrum is your application. The best approach, > of course, is to create a test that mimics your application's > workload and see how each database performs. Luckily, with ODB, > it will be very easy to write a simple test that you can run > against every database. > > > > One more question: What would people recommend for modeling a ?graph? as > a > > persistent data type in odb. I use boost::graph currently. I am trying > to > > think of a way to do it in ODB is not too awfully slow/clumsy/messy. Just > > wondering if it has been done before. > > When mapping a C++ class to a database class in ODB, there are > generally three ways to do it: > > 1. Map it to a corresponding database type (e.g., if your target > database supported the graph data type or something similar). > > 2. Map it to some kind of a "database data structure", i.e., > one or more columns and/or tables that capture the data > in a suitable form. > > In your case, for example, this could mean having column(s) > that contain containers (in PG) that represents the graph. > > Or, perhaps, it makes sense to map it as a container. See, > for instance, how we mapped the Boost multi-index container > in the libodb-boost profile. > > 3. Map it to an opaque data structure, i.e., a BLOB. In this > case you simply store some binary representation of your > data structure. > > Which way is best depends on your requirements. (1) is of > course the cleanest but I don't think there are build-in > graph types supported by the databases we are talking about. > I guess, one way to approach is to ask yourself how would > you persist your graphs in a text file. Then try to model > this format using (2). I unfortunately not familiar enough > with the way these two graph types store their internal > representations so cannot really suggest which way is best. > > But if you can outline what would be a good "on disk" > representation, I could suggest how to map it to the > database. > > Boris > From konstantin.tarovik at ab-soft.net Thu Jun 4 10:41:45 2015 From: konstantin.tarovik at ab-soft.net (Konstantin Tarovik) Date: Fri Jun 5 01:51:23 2015 Subject: [odb-users] _cache_persist not called Message-ID: <557063A9.1000708@ab-soft.net> Hi all, I have an issue with implementing custom session and receiving notifications. The problem is that I receive _cache_insert, _cache_find and _cache_erase calls but _cache_persist is never called even though a lot of objects are stored to DB. Please advice. Best regards, Konstantin Tarovik From andrew at a-cunningham.com Thu Jun 4 17:00:30 2015 From: andrew at a-cunningham.com (Andrew Cunningham) Date: Fri Jun 5 01:51:23 2015 Subject: [odb-users] lazy_ptr and operator-> Message-ID: Hi, A bit of a newbie question... search did not answer this one... I was wondering why ODB does not do an automatic load() when the operator-> of a lazy pointer is called? The explicit use of load() seems quite a burden. From boris at codesynthesis.com Fri Jun 5 12:51:02 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jun 5 12:51:10 2015 Subject: [odb-users] _cache_persist not called In-Reply-To: <557063A9.1000708@ab-soft.net> References: <557063A9.1000708@ab-soft.net> Message-ID: Hi Konstantin, Konstantin Tarovik writes: > I have an issue with implementing custom session and receiving > notifications. The problem is that I receive _cache_insert, > _cache_find and _cache_erase calls but _cache_persist is never > called even though a lot of objects are stored to DB. Take a look at the common/session/custom test in odb-tests. It implements a custom session, including _cache_persist(). See if you can spot what you are doing differently, if anything. If that doesn't help, then I would need a test case that I can debug myself. Without it I would be just guessing. Boris From boris at codesynthesis.com Fri Jun 5 12:52:51 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jun 5 12:53:00 2015 Subject: [odb-users] lazy_ptr and operator-> In-Reply-To: References: Message-ID: Hi Andrew, Andrew Cunningham writes: > I was wondering why ODB does not do an automatic load() when the > operator-> of a lazy pointer is called? > The explicit use of load() seems quite a burden. The reason is this: you have to call load() within a transaction. Making operator->() implicitly call it would be very error prone. Boris From konstantin.tarovik at ab-soft.net Mon Jun 8 11:17:09 2015 From: konstantin.tarovik at ab-soft.net (Konstantin Tarovik) Date: Tue Jun 9 07:31:52 2015 Subject: [odb-users] _cache_persist not called In-Reply-To: References: <557063A9.1000708@ab-soft.net> Message-ID: <5575B1F5.2020104@ab-soft.net> Hi Boris, Looks like the problem arises when I use smart pointers (i.e. #pragma db object(Conversation) pointer(std::shared_ptr) ). Is there a way to use smart pointers but still receive notifications? Thank you. On 6/5/15 7:51 PM, Boris Kolpackov wrote: > Hi Konstantin, > > Konstantin Tarovik writes: > >> I have an issue with implementing custom session and receiving >> notifications. The problem is that I receive _cache_insert, >> _cache_find and _cache_erase calls but _cache_persist is never >> called even though a lot of objects are stored to DB. > Take a look at the common/session/custom test in odb-tests. It > implements a custom session, including _cache_persist(). See if > you can spot what you are doing differently, if anything. > > If that doesn't help, then I would need a test case that I > can debug myself. Without it I would be just guessing. > > Boris -- Best regards, Konstantin Tarovik From christian at gsvitec.com Tue Jun 9 08:27:07 2015 From: christian at gsvitec.com (Christian Sell) Date: Tue Jun 9 08:27:10 2015 Subject: [odb-users] compile error with libodb-qt module Message-ID: <1923999825.1718034.1433852827400.JavaMail.open-xchange@omgreatgod.store> Hello, I am setting up a fresh development environment with ODB 2.4, Linux Mint 17 and Qt 5.4.2 (64 bit). Not that this is the fist time that I have done seomething similar - but this is the first time I see the following error message when compiling the libodb-qt module: QtCore/qglobal.h:1052:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (-fPIE is not enough)." # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ I was able to fix that by setting the CXXFLAGS environment variable to "-fPIC" before doing the ./configure. However, now when compiling my own code, I am getting the same message when the ODB compiler is invoked - and I have not been able to figure out how to mend this. Can anybody hint as to the reason why this occurs, and how to deal with it? thanks, Christian From boris at codesynthesis.com Tue Jun 9 09:40:15 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 9 09:40:19 2015 Subject: [odb-users] _cache_persist not called In-Reply-To: <5575B1F5.2020104@ab-soft.net> References: <557063A9.1000708@ab-soft.net> <5575B1F5.2020104@ab-soft.net> Message-ID: Hi Konstantin, Konstantin Tarovik writes: > Looks like the problem arises when I use smart pointers (i.e. > #pragma db object(Conversation) pointer(std::shared_ptr) ). Ok, I think I know what's going on. If you use shared_ptr (or any other smart pointer) as an object pointer, the session no longer caches objects that were passed to persist() by reference (since we cannot assume it's ok to use the reference to initialize the smart pointer). In other words: shared_ptr o = ...; db.persist (*o); // Not cached. db.persist (o); // Cached. Boris From boris at codesynthesis.com Tue Jun 9 09:52:55 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 9 09:52:59 2015 Subject: [odb-users] compile error with libodb-qt module In-Reply-To: <1923999825.1718034.1433852827400.JavaMail.open-xchange@omgreatgod.store> References: <1923999825.1718034.1433852827400.JavaMail.open-xchange@omgreatgod.store> Message-ID: Hi Christian, Christian Sell writes: > I am setting up a fresh development environment with ODB 2.4, Linux Mint 17 and > Qt 5.4.2 (64 bit). Not that this is the fist time that I have done seomething > similar - but this is the first time I see the following error message when > compiling the libodb-qt module: > > QtCore/qglobal.h:1052:4: error: #error "You must build your code with position > independent code if Qt was built with -reduce-relocations. " "Compile your code > with -fPIC (-fPIE is not enough)." > # error "You must build your code with position independent code if Qt was built > with -reduce-relocations. "\ > > I was able to fix that by setting the CXXFLAGS environment variable to "-fPIC" > before doing the ./configure. However, now when compiling my own code, I am > getting the same message when the ODB compiler is invoked - and I have not been > able to figure out how to mend this. Can anybody hint as to the reason why this > occurs, and how to deal with it? I assume you have the Qt profile enabled when running the ODB compiler. If so, libodb-qt tries to take care of this: see odb/qt/details/config.hxx for how and a detailed explanation of what's going on. But I guess the Qt folks changed something in more recent versions of Qt so that whatever we are doing no longer works. Would you be able to try and figure out why? Specifically, take a look into QtCore/qglobal.h:1052 and see why defining __PIE__ is no longer sufficient. Also, maybe Qt no longer defines QT_REDUCE_RELOCATIONS? Thanks, Boris From christian at gsvitec.com Tue Jun 9 10:43:25 2015 From: christian at gsvitec.com (Christian Sell) Date: Tue Jun 9 10:43:27 2015 Subject: [odb-users] compile error with libodb-qt module In-Reply-To: References: <1923999825.1718034.1433852827400.JavaMail.open-xchange@omgreatgod.store> Message-ID: <458419549.1755673.1433861005354.JavaMail.open-xchange@omgreatgod.store> Hello Boris, the lines in qglobal.h read #if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && \ (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= 500)) # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ "Compile your code with -fPIC (-fPIE is not enough)." my IDE tells me that QT_REDUCE_RELOCATION, Q_CC_GNU and Q_CC_GNU are defined. QT_REDUCE_RELOCATION is #defined right at the top of QtCore/qconfig.h. However, the error message clearly states tat __PIE__ is not enough, and that is what you set in your header. I first assumed this was the problem, but found that adding -x -fPIE to my odb command line fixed the problem.. mysterious. let me know where else to look, Christian > Boris Kolpackov hat am 9. Juni 2015 um 15:52 > geschrieben: > > > Hi Christian, > > Christian Sell writes: > > > I am setting up a fresh development environment with ODB 2.4, Linux Mint 17 > > and > > Qt 5.4.2 (64 bit). Not that this is the fist time that I have done > > seomething > > similar - but this is the first time I see the following error message when > > compiling the libodb-qt module: > > > > QtCore/qglobal.h:1052:4: error: #error "You must build your code with > > position > > independent code if Qt was built with -reduce-relocations. " "Compile your > > code > > with -fPIC (-fPIE is not enough)." > > # error "You must build your code with position independent code if Qt was > > built > > with -reduce-relocations. "\ > > > > I was able to fix that by setting the CXXFLAGS environment variable to > > "-fPIC" > > before doing the ./configure. However, now when compiling my own code, I am > > getting the same message when the ODB compiler is invoked - and I have not > > been > > able to figure out how to mend this. Can anybody hint as to the reason why > > this > > occurs, and how to deal with it? > > I assume you have the Qt profile enabled when running the ODB compiler. > If so, libodb-qt tries to take care of this: see odb/qt/details/config.hxx > for how and a detailed explanation of what's going on. But I guess > the Qt folks changed something in more recent versions of Qt so that > whatever we are doing no longer works. Would you be able to try and > figure out why? > > Specifically, take a look into QtCore/qglobal.h:1052 and see why > defining __PIE__ is no longer sufficient. Also, maybe Qt no longer > defines QT_REDUCE_RELOCATIONS? > > Thanks, > Boris From boris at codesynthesis.com Tue Jun 9 11:26:47 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 9 11:26:52 2015 Subject: [odb-users] compile error with libodb-qt module In-Reply-To: <458419549.1755673.1433861005354.JavaMail.open-xchange@omgreatgod.store> References: <1923999825.1718034.1433852827400.JavaMail.open-xchange@omgreatgod.store> <458419549.1755673.1433861005354.JavaMail.open-xchange@omgreatgod.store> Message-ID: Hi Christian, Christian Sell writes: > #if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && > defined(__ELF__) && \ > (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= > 500)) > > However, the error message clearly states tat __PIE__ is not enough, and that is > what you set in your header. I first assumed this was the problem, but found > that adding -x -fPIE to my odb command line fixed the problem.. mysterious. >From that #if I recon PIE is not enough only for GCC 5 and later. So as long as ODB is not using GCC 5 in your case, adding -x -fPIE should be enough. What is strange is that the #define in libodb-qt doesn't work. Can you confirm that you have '-p qt' option on the ODB command line? If the answer is yes, can you put #error just before #define __PIE__ in config.hxx and see if it trips? Thanks, Boris From sean.clarke at sec-consulting.co.uk Fri Jun 12 17:24:21 2015 From: sean.clarke at sec-consulting.co.uk (Sean Clarke) Date: Fri Jun 12 17:24:28 2015 Subject: [odb-users] Odd behaviour with odb::result container Message-ID: Hi folks, I have an odd issue whereby I see different behaviour if I pass odb::result containers to STL functions.... In a small test example I query the DB and retrieve say 20 invoices, if I iterate over the invoices (this is just dummy test code): for(const auto& invoice : iresult) { invoice.id(); std::cout << "nett amount = ?" << std::setprecision(2) << std::fixed << invoice.nett_amount() << std::endl; } I see lots of output.... however if I then pass the same container to an STL function accumulate: double average = std::accumulate(std::begin(iresult), std::end(iresult), 0.0, [](const double sum, const Invoice& i) { return sum + i.nett_amount(); }); I get zero returned. If I change the accumulate lambda to count it's iterations it never gets called (its like iresult.begin() == iresult.end() ). If I remove that initial dummy for loop iterating over the container then the accumulate function works fine. Similarly, if I remove the accumulate function and add another for loop it again works fine. Any ideas to explain what I am seeing? Regards Sean Clarke From boris at codesynthesis.com Mon Jun 15 11:45:46 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 15 11:45:49 2015 Subject: [odb-users] Odd behaviour with odb::result container In-Reply-To: References: Message-ID: Hi Sean, Sean Clarke writes: > If I remove that initial dummy for loop iterating over the container then > the accumulate function works fine. Result iterator is an input iterator (Section 4.4, "Query Result") which means you can iterate over it only once. Think of it as a stream (which in many database systems it is; the server sends the rows as we consume them). While this one-pass semantics is implied by input iterator, I've added an explicit note to the ODB manual to this effect. Boris From boris at codesynthesis.com Tue Jun 16 09:01:00 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 16 09:01:03 2015 Subject: [odb-users] ODB in Debian Message-ID: Hi, I am not sure if many noticed, thanks to persistent effort of L?szl? B?sz?rm?nyi, ODB 2.4.0 is now packaged for Debian and available in the 'testing' and 'unstable' Debian repositories as well as the 'wily' Ubuntu repository. This includes the full set of packages: the ODB compiler, the runtimes for all the open source databases (MySQL, PostgreSQL, and SQLite) as well as both profile libraries (Qt and Boost). Thanks again to L?szl? for his work! Boris From finjulhich at gmail.com Tue Jun 16 09:59:38 2015 From: finjulhich at gmail.com (MM) Date: Tue Jun 16 09:59:46 2015 Subject: [odb-users] tagging a base struct member as id Message-ID: As far as I can see from the manual, this should be possible: namespace N { //// in header1 in ~/mydir struct Base { std::uint32_t id; virtual ~Base() =0; }; } namespace N { /// in header2 ~/mydir , includes header1 struct Derived : public Base { ... }; } namespace N { //// in header3 in ~/mydir_odb, includes header2 from ~/mydir #pragma db object(Derived) table("mytable") definition #pragma db member(Derived::id) id auto } Running odb 2.3.0 like this: odb -d sqlite --sqlite-override-null --std c++11 --profile boost --omit-drop --generate-schema-only --schema-format sql --at-once --changelog-dir -I~/mydir --input-name .... ~/mydir_odb/.hpp yields this error: header2.hpp:39:8: error: no data member designated as an object id header2:39:8: info: use '#pragma db id' to specify an object id member header2:39:8: info: or explicitly declare that this persistent class has no object id with '#pragma db object no_id' This looks similar to the permanent_employee example in the manual.... But I am surely missing something obvious, apologies if so. Rds, MM From boris at codesynthesis.com Wed Jun 17 06:44:30 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 17 06:44:32 2015 Subject: [odb-users] tagging a base struct member as id In-Reply-To: References: Message-ID: Hi, MM writes: > struct Base { > std::uint32_t id; > virtual ~Base() =0; > }; > > struct Derived : public Base { > ... > }; > > #pragma db object(Derived) table("mytable") definition > #pragma db member(Derived::id) id auto I believe the problem is due to the id member being in Base, which is transient. If having it transient is the intention, then you can still achieve what you want using a virtual data member: #pragma db member(Derived::id) virtual(std::uint32_t) access(Base::id) id auto Boris From finjulhich at gmail.com Thu Jun 18 05:21:40 2015 From: finjulhich at gmail.com (MM) Date: Thu Jun 18 05:21:48 2015 Subject: [odb-users] tagging a base struct member as id In-Reply-To: References: Message-ID: On 17 June 2015 at 11:44, Boris Kolpackov wrote: > Hi, > > MM writes: > > > struct Base { > > std::uint32_t id; > > virtual ~Base() =0; > > }; > > > > struct Derived : public Base { > > ... > > }; > > > > #pragma db object(Derived) table("mytable") definition > > #pragma db member(Derived::id) id auto > > I believe the problem is due to the id member being in Base, > which is transient. If having it transient is the intention, > then you can still achieve what you want using a virtual data > member: > > #pragma db member(Derived::id) virtual(std::uint32_t) access(Base::id) id > auto > > Boris > derived_odb.hpp:33:12: error: virtual data member declaration 'id' conflicts with a previous declaration base.hpp:23:22: info: 'id' was previously declared here the sql table for derived has a column named 'id' From boris at codesynthesis.com Thu Jun 18 10:07:30 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 18 10:07:31 2015 Subject: [odb-users] tagging a base struct member as id In-Reply-To: References: Message-ID: Hi, MM writes: > > #pragma db member(Derived::id) virtual(std::uint32_t) access(Base::id) id > > derived_odb.hpp:33:12: error: virtual data member declaration 'id' > conflicts with a previous declaration > base.hpp:23:22: info: 'id' was previously declared here Ok, use member(Derived::id_) instead. This name is only used to derive the column name, so you will still end up with a column called 'id'. Boris From nicholas.cremonesi at gmail.com Mon Jun 22 04:27:27 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Mon Jun 22 09:20:53 2015 Subject: [odb-users] From odb::nullable to float Message-ID: Hello everyone, I need to convert data from the db which are setted to odb:nulllable to "simple" float. How can I do that? Many thanks From boris at codesynthesis.com Mon Jun 22 09:39:05 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 22 09:39:02 2015 Subject: [odb-users] From odb::nullable to float In-Reply-To: References: Message-ID: Nicholas Cremonesi writes: > I need to convert data from the db which are setted to odb:nulllable > to "simple" float. > > How can I do that? By reading the manual. Specifically, Section 7.3, "Pointers and NULL Value Semantics". Boris From viva.cpp at gmail.com Mon Jun 22 11:31:43 2015 From: viva.cpp at gmail.com (=?UTF-8?B?0JjQstCw0L0g0KDQvtC80LDQvdC10L3QutC+?=) Date: Mon Jun 22 12:10:51 2015 Subject: [odb-users] Bulk insert for SQLite Message-ID: Hello, In SQLite 3.7.11(2012-03-20) added INSERT syntax to allow multiple rows to be inserted via the VALUES clause. So it is possible to implement bulk insert for SQLite. 1. Why ODB do not support bulk insert for SQLite ? 2. Does it improve performace of insert operations for large amount of objects( > 1 million) for SQLite ? From qgjie at 163.com Tue Jun 23 04:17:55 2015 From: qgjie at 163.com (qgjie) Date: Tue Jun 23 04:18:00 2015 Subject: [odb-users] odb value Type In-Reply-To: References: Message-ID: <2a8d9332.db4d.14e1f7eb79c.Coremail.qgjie@163.com> my code: class nurse { public: nurse(long i): id(i),city(0),sex(2),star(5),birthday(0),outTotal(0),inTotal(0) { } virtual ~nurse() {} bool setUnfilledOrderStatus(nurse_type p, long appid, int s); private: friend class odb::access; set orders; }; class unfilledOrder { public: unfilledOrder(long appid, long pat): appointid(appid), patient(pat) {} void setStatus(int s) { status = s; } private: friend class nurse; friend class odb::access; unfilledOrder(){} long appointid; long patient; long hospital; long btime; int type; int paytype; int money; int status; string patientname; string patientphone; }; #ifdef ODB_COMPILER #pragma db value(unfilledOrder) #pragma db object(nurse) #pragma db member(nurse::id) id #endif I want to modify the status value of the unfilledOrder, why it not ? who can help me! the code: bool nurse::setUnfilledOrderStatus(nurse_type p, long appid, int s) { unfilledOrder u; set::iterator it; for(it = orders.begin(); it != orders.end(); ++it) { if(it->getAppointId() == appid) { u = (*it); orders.erase(it); u.setStatus(s); orders.insert(u); odb::core::transaction t (getDatabase()->begin ()); try { update(p); return true; } catch (const odb::exception& e) { std::cout << "nurse::setUnfilledOrderStatus:"<< e.what() << std::endl; } t.commit (); return false; } } return false; } From boris at codesynthesis.com Tue Jun 23 10:04:54 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 23 10:04:50 2015 Subject: [odb-users] Bulk insert for SQLite In-Reply-To: References: Message-ID: Hi Ivan, ???? ????????? writes: > In SQLite 3.7.11(2012-03-20) added INSERT > syntax to allow multiple rows to > be inserted via the VALUES clause. > > So it is possible to implement bulk insert for SQLite. > > 1. Why ODB do not support bulk insert for SQLite ? Well, this is not quite the bulk insert that you find in, say, Oracle or SQL Server (which ODB supports). In those databases you execute a single INSERT (i.e., with a single row in VALUES) multiple time on an array or rows (say 10,000 rows per batch). What we have in SQLite is the ability to have an INSERT statement with multiple rows in VALUES. So if we wanted to insert 10,000 rows at a time, the INSERT statement (i.e., its literal text) would have to have 10,000 rows: "INSERT INTO ... VALUES (?, ... ?), (?, ... ?), (?, ... ?), ..." So that would be one giant statement. We would also have to bind data for all 10,000 rows at once. That's a lot of bindings. So, overall, for the way ODB uses SQLite statements (i.e., prepared with parameter binding), this feels like the wrong way to do it and which will most likely results in worse performance. But, if you (or someone else) wants to create a benchmark, I am willing to be proven wrong ;-). > 2. Does it improve performace of insert operations for large > amount of objects( > 1 million) for SQLite? As I said above, I would very much doubt it. My feeling is that it will be a lot slower. One of the main bottlenecks of SQLite insert is foreign key constraint checking. So if you need to insert, say, 1M rows and you can make sure no FK violations are possible, it would make sense to temporary disable FK checking for such a transaction. Also splitting this insertion into several smaller transactions might help. Boris From selection989 at gmail.com Wed Jun 24 11:52:42 2015 From: selection989 at gmail.com (Teererai Marange) Date: Wed Jun 24 13:07:25 2015 Subject: [odb-users] error during linking process for hello world example with sqlite database Message-ID: In attempting to get the hello world example program from the documentation to work, I am failing to link the application using the following command entered in terminal: g++ -o driver driver.o person-odb.o -L/usr/local/lib/libodb-sqlite-2.4.so -lodb-mysql -lodb The following error is returned by terminal: /usr/bin/ld: cannot find -lodb-mysql collect2: error: ld returned 1 exit status Upon installation of libodb-sqlite-2.4, I was informed that the libraries were located in /usr/local/lib and can confirm that the shared objects do indeed exist there. In addition to this, I am using libodb-2.4 and am using g++ version 4.8. -- Regards, Teererai Marange From alexandre.pretyman at gmail.com Wed Jun 24 14:04:27 2015 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Wed Jun 24 14:05:04 2015 Subject: [odb-users] error during linking process for hello world example with sqlite database In-Reply-To: References: Message-ID: You seem to be missing the argument to tell the linker to actually look in /usr/local/lib: -L/usr/local/lib -lodb-mysql For more information, you can follow this link: http://bfy.tw/V1d =) On 24 June 2015 at 11:52, Teererai Marange wrote: > In attempting to get the hello world example program from the documentation > to work, I am failing to link the application using the following command > entered in terminal: > > g++ -o driver driver.o person-odb.o -L/usr/local/lib/libodb-sqlite-2.4.so > -lodb-mysql -lodb > > The following error is returned by terminal: > > /usr/bin/ld: cannot find -lodb-mysql > collect2: error: ld returned 1 exit status > > Upon installation of libodb-sqlite-2.4, I was informed that the libraries > were located in /usr/local/lib and can confirm that the shared objects do > indeed exist there. In addition to this, I am using libodb-2.4 and am using > g++ version 4.8. > > > > -- > Regards, > > Teererai Marange > -- Alexandre Pretyman From selection989 at gmail.com Wed Jun 24 23:41:59 2015 From: selection989 at gmail.com (Teererai Marange) Date: Thu Jun 25 07:43:02 2015 Subject: [odb-users] error during linking process for hello world example with sqlite database In-Reply-To: References: Message-ID: Thanks for the quick response, however I have encountered another issue. When I perform the linking once again with the command: g++ -o driver driver.o person-odb.o -lodb-sqlite -lodb -L\usr\local\lib The following error is returned: driver.o: In function `main': driver.cpp:(.text+0x76): undefined reference to `person::person(std::string const&, std::string const&, unsigned short)' driver.cpp:(.text+0x110): undefined reference to `person::person(std::string const&, std::string const&, unsigned short)' driver.cpp:(.text+0x1b3): undefined reference to `person::person(std::string const&, std::string const&, unsigned short)' collect2: error: ld returned 1 exit status The code for driver.cpp is shown below: // driver.cpp // #include // std::auto_ptr #include #include #include #include #include "person.hpp" #include "person-odb.hxx" using namespace std; using namespace odb::core; int main (int argc, char* argv[]) { person john ("John", "Doe", 33); person jane ("Jane", "Doe", 32); person joe ("Joe", "Dirt", 30); transaction t (db->begin ()); // Make objects persistent and save their ids for later use. // john_id = db->persist (john); jane_id = db->persist (jane); joe_id = db->persist (joe); t.commit (); } } catch (const odb::exception& e) { cerr << e.what () << endl; return 1; } } person.hpp is shown below: // person.hpp // #ifndef PERSON_HPP #define PERSON_HPP #include #include #pragma db object class person { public: person (const std::string& first, const std::string& last, unsigned short age); const std::string& first () const; const std::string& last () const; unsigned short age () const; void age (unsigned short); private: person(){}; friend class odb::access; #pragma db id auto unsigned long id_; std::string first_; std::string last_; unsigned short age_; }; #endif I am new to linking in general so any assistance would be appreciated. On Thu, Jun 25, 2015 at 6:04 AM, Alexandre Pretyman < alexandre.pretyman@gmail.com> wrote: > You seem to be missing the argument to tell the linker to actually look in /usr/local/lib: > -L/usr/local/lib -lodb-mysql > > For more information, you can follow this link: http://bfy.tw/V1d =) > > On 24 June 2015 at 11:52, Teererai Marange wrote: > >> In attempting to get the hello world example program from the >> documentation >> to work, I am failing to link the application using the following command >> entered in terminal: >> >> g++ -o driver driver.o person-odb.o -L/usr/local/lib/ >> libodb-sqlite-2.4.so >> -lodb-mysql -lodb >> >> The following error is returned by terminal: >> >> /usr/bin/ld: cannot find -lodb-mysql >> collect2: error: ld returned 1 exit status >> >> Upon installation of libodb-sqlite-2.4, I was informed that the libraries >> were located in /usr/local/lib and can confirm that the shared objects do >> indeed exist there. In addition to this, I am using libodb-2.4 and am >> using >> g++ version 4.8. >> >> >> >> -- >> Regards, >> >> Teererai Marange >> > > > > -- > Alexandre Pretyman > -- Regards, Teererai Marange Ph: 021521987 From selection989 at gmail.com Thu Jun 25 00:04:34 2015 From: selection989 at gmail.com (Teererai Marange) Date: Thu Jun 25 07:43:02 2015 Subject: [odb-users] error during linking process for hello world example with sqlite database In-Reply-To: References: Message-ID: Found the solution: For anyone else who has had the same problem, the hello world example documentation doesnt mention that you need to actually define person::person(std::string const&, std::string const&, unsigned short) within a cpp file or actually define it in person.hxx. On Thu, Jun 25, 2015 at 3:41 PM, Teererai Marange wrote: > Thanks for the quick response, however I have encountered another issue. > When I perform the linking once again with the command: > > g++ -o driver driver.o person-odb.o -lodb-sqlite -lodb -L\usr\local\lib > > The following error is returned: > > driver.o: In function `main': > driver.cpp:(.text+0x76): undefined reference to > `person::person(std::string const&, std::string const&, unsigned short)' > driver.cpp:(.text+0x110): undefined reference to > `person::person(std::string const&, std::string const&, unsigned short)' > driver.cpp:(.text+0x1b3): undefined reference to > `person::person(std::string const&, std::string const&, unsigned short)' > collect2: error: ld returned 1 exit status > > The code for driver.cpp is shown below: > > > // driver.cpp > // > > #include // std::auto_ptr > #include > > #include > #include > > #include > > #include "person.hpp" > #include "person-odb.hxx" > > using namespace std; > using namespace odb::core; > > int > main (int argc, char* argv[]) > { > person john ("John", "Doe", 33); > person jane ("Jane", "Doe", 32); > person joe ("Joe", "Dirt", 30); > > transaction t (db->begin ()); > > // Make objects persistent and save their ids for later use. > // > john_id = db->persist (john); > jane_id = db->persist (jane); > joe_id = db->persist (joe); > > t.commit (); > } > } > catch (const odb::exception& e) > { > cerr << e.what () << endl; > return 1; > } > } > > person.hpp is shown below: > > > // person.hpp > // > #ifndef PERSON_HPP > #define PERSON_HPP > > #include > #include > > #pragma db object > class person > { > public: > person (const std::string& first, > const std::string& last, > unsigned short age); > > const std::string& first () const; > const std::string& last () const; > > unsigned short age () const; > void age (unsigned short); > > private: > person(){}; > > friend class odb::access; > > #pragma db id auto > unsigned long id_; > std::string first_; > std::string last_; > unsigned short age_; > }; > > #endif > > I am new to linking in general so any assistance would be appreciated. > > > > > On Thu, Jun 25, 2015 at 6:04 AM, Alexandre Pretyman < > alexandre.pretyman@gmail.com> wrote: > >> You seem to be missing the argument to tell the linker to actually look >> in /usr/local/lib: -L/usr/local/lib -lodb-mysql >> >> For more information, you can follow this link: http://bfy.tw/V1d =) >> >> On 24 June 2015 at 11:52, Teererai Marange >> wrote: >> >>> In attempting to get the hello world example program from the >>> documentation >>> to work, I am failing to link the application using the following command >>> entered in terminal: >>> >>> g++ -o driver driver.o person-odb.o -L/usr/local/lib/ >>> libodb-sqlite-2.4.so >>> -lodb-mysql -lodb >>> >>> The following error is returned by terminal: >>> >>> /usr/bin/ld: cannot find -lodb-mysql >>> collect2: error: ld returned 1 exit status >>> >>> Upon installation of libodb-sqlite-2.4, I was informed that the libraries >>> were located in /usr/local/lib and can confirm that the shared objects do >>> indeed exist there. In addition to this, I am using libodb-2.4 and am >>> using >>> g++ version 4.8. >>> >>> >>> >>> -- >>> Regards, >>> >>> Teererai Marange >>> >> >> >> >> -- >> Alexandre Pretyman >> > > > > -- > Regards, > > Teererai Marange > Ph: 021521987 > -- Regards, Teererai Marange Ph: 021521987 From dieter.govaerts at bricsys.com Thu Jun 25 03:49:23 2015 From: dieter.govaerts at bricsys.com (dieter.govaerts@bricsys.com) Date: Thu Jun 25 07:43:02 2015 Subject: [odb-users] Pimpl idiom and index definition pragma Message-ID: <1435218563.398829146@apps.rackspace.com> Hello everyone, I'm using the pimpl idiom for my classes but I can't get to define a unique index over multiple columns with it. enum ObjectType { //... }; #pragma db object transient class CustomProperty : public std::enable_shared_from_this { public: unsigned int id() const; String const & name() const; void name(String const & value); ObjectType object_type() const; private: #pragma db id auto #pragma db member(id) virtual(unsigned int) get(this.impl().m_id) set(this.impl().m_id) #pragma db member(name) virtual(String) access(this.impl().m_name) #pragma db member(object_type) virtual(ObjectType) get(this.impl().m_object_type) set(const_cast< bim_lib::ObjectType & >(this.impl().m_object_type)) #pragma db index("object_type_name_i") member(impl_.m_object_type) member(impl_.m_name) unique friend class odb::access; public: ~CustomProperty(); protected: class Impl; CustomProperty(); CustomProperty(Impl *); private: Impl * const impl_; }; No mater what I try to put between the member clauses for the object_type_name_i index, it always fails with the error: bim_lib_custom_props.h:48:44: error: data member 'impl_' specified in db pragma member is not composite How can I solve this? Thanks in advance. Dieter Govaerts From boris at codesynthesis.com Thu Jun 25 07:48:38 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 25 07:48:32 2015 Subject: [odb-users] odb value Type In-Reply-To: <2a8d9332.db4d.14e1f7eb79c.Coremail.qgjie@163.com> References: <2a8d9332.db4d.14e1f7eb79c.Coremail.qgjie@163.com> Message-ID: Hi, In the future, please start a new email rather than replying to an existing email (even though you have changed the subject, the In-Reply-To: header still links it to the original email). qgjie writes: > bool nurse::setUnfilledOrderStatus(nurse_type p, long appid, int s) > { > unfilledOrder u; > set::iterator it; > for(it = orders.begin(); it != orders.end(); ++it) > { > if(it->getAppointId() == appid) > { > u = (*it); > orders.erase(it); > u.setStatus(s); > orders.insert(u); > odb::core::transaction t (getDatabase()->begin ()); > try { > update(p); I don't know what 'nurse_type' or 'p' is, but shouldn't you be updating what you have modified: update(*this); Boris From boris at codesynthesis.com Thu Jun 25 07:52:20 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 25 07:52:14 2015 Subject: [odb-users] Pimpl idiom and index definition pragma In-Reply-To: <1435218563.398829146@apps.rackspace.com> References: <1435218563.398829146@apps.rackspace.com> Message-ID: Hi Dieter, dieter.govaerts@bricsys.com writes: > #pragma db object transient > class CustomProperty > { > > ... > > #pragma db id auto > #pragma db member(id) virtual(unsigned int) get(this.impl().m_id) set(this.impl().m_id) > #pragma db member(name) virtual(String) access(this.impl().m_name) > #pragma db member(object_type) virtual(ObjectType) get(this.impl().m_object_type) set(const_cast< bim_lib::ObjectType & >(this.impl().m_object_type)) > #pragma db index("object_type_name_i") member(impl_.m_object_type) member(impl_.m_name) unique > > private: > Impl * const impl_; > }; > > No mater what I try to put between the member clauses for the > object_type_name_i index, it always fails with the error: > > bim_lib_custom_props.h:48:44: error: data member 'impl_' specified > in db pragma member is not composite Your impl_ member is transient. Indexes can only be based on the persistent members. In your case, you should just use the virtual members: #pragma db index("object_type_name_i") members(object_type, name) unique Nice and simple. Boris From finjulhich at gmail.com Fri Jun 26 08:48:21 2015 From: finjulhich at gmail.com (MM) Date: Fri Jun 26 08:48:30 2015 Subject: [odb-users] base class, derived, separate headers and derived references base Message-ID: Hi, I believe I have a case similar to: http://www.codesynthesis.com/pipermail/odb-users/2012-June/000625.html with separate headers for base and derived. Is this something that may have been addressed after some particular version? I run 2.3.0 Regards, From boris at codesynthesis.com Fri Jun 26 11:32:48 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jun 26 11:32:41 2015 Subject: [odb-users] base class, derived, separate headers and derived references base In-Reply-To: References: Message-ID: Hi, MM writes: > Is this something that may have been addressed after some particular > version? > > I run 2.3.0 I think so. Why don't you try 2.4.0? Boris