From kuentzer at googlemail.com Mon Jul 4 11:29:14 2011 From: kuentzer at googlemail.com (Jan Kuentzer) Date: Mon Jul 4 11:58:09 2011 Subject: [odb-users] Query std::vector or object relationships Message-ID: Hi, I generated with ODB for our project successfully the sql code and was able to serialize objects into the database. It is really fast and the data is stored in the db schema. After that I tried to search for objects using the query capabilities from ODB. For simple datatypes like std::string or int this works pretty fine, but for container like std::vector attributes I always get the compile error "is not a member of odb::query<..." As an example the class Xref has a std::string attribute called "db" and for this the following works fine: odb::query< Xref> q (odb::query< Xref>::db == "some_string"); But the class UtilityClass has a std::vector attribute called "comment" and for this the following gives the mentioned compile error: odb::query q (odb::query::comment == "some_string"); The same is true for a Class with std::vector attribute. This also doesn't compile when using the attribute names as shown in employee-employer example. Do I use the odb::query in a wrong way? Thanks in advance for your help ! -------------- next part -------------- A non-text attachment was scrubbed... Name: UtilityClass.h Type: text/x-chdr Size: 739 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20110704/847c1844/UtilityClass.h From boris at codesynthesis.com Mon Jul 4 12:09:21 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 4 12:12:00 2011 Subject: [odb-users] Query std::vector or object relationships In-Reply-To: References: Message-ID: Hi Jan, Jan Kuentzer writes: > But the class UtilityClass has a std::vector attribute called > "comment" and for this the following gives the mentioned compile error: > odb::query q (odb::query::comment == > "some_string"); There is currently no support for using container members as predicates in the C++-integrated queries. As a workaround for the meantime you can use native queries (which are essentially the SQL WHERE text). Also, for when we get to supporting this, it would be helpful to know what kind operations you expect to be able to perform on container. The one that you use above doesn't make much sense since a vector of strings cannot be meaningfully compared to a string. Maybe something like this: odb::query::comment.contains ("some_string") Or odb::query::comment[0] == "some_string" ? Boris From kuentzer at googlemail.com Mon Jul 4 12:35:58 2011 From: kuentzer at googlemail.com (=?utf-8?Q?Jan_K=C3=BCntzer?=) Date: Mon Jul 4 13:02:21 2011 Subject: [odb-users] Query std::vector or object relationships In-Reply-To: References: Message-ID: <51DD4515-74FE-48E3-9F26-C6A788E3DFF2@googlemail.com> Hi Boris Thanks for the fast reply You are right, what i would like to have in this example is the contains function. Another nice thing would be: For a vector of pointers, e.g. vector xrefs and Xref with string attribut db, it would be nice to have a chance for checking if one of the xrefs has the stated attribute. Something like odb::query::xrefs::db = "some_string" ? Jan Am 04.07.2011 um 18:09 schrieb Boris Kolpackov : > Hi Jan, > > Jan Kuentzer writes: > >> But the class UtilityClass has a std::vector attribute called >> "comment" and for this the following gives the mentioned compile error: >> odb::query q (odb::query::comment == >> "some_string"); > > There is currently no support for using container members as predicates > in the C++-integrated queries. As a workaround for the meantime you can > use native queries (which are essentially the SQL WHERE text). > > Also, for when we get to supporting this, it would be helpful to know what > kind operations you expect to be able to perform on container. The one > that you use above doesn't make much sense since a vector of strings > cannot be meaningfully compared to a string. Maybe something like this: > > odb::query::comment.contains ("some_string") > > Or > > odb::query::comment[0] == "some_string" > > ? > > Boris From gerasch at informatik.uni-tuebingen.de Tue Jul 5 09:03:41 2011 From: gerasch at informatik.uni-tuebingen.de (Andreas Gerasch) Date: Tue Jul 5 09:03:50 2011 Subject: [odb-users] Object not persistent Message-ID: <4E130BAD.9040906@informatik.uni-tuebingen.de> Hi, we currently try to integrate your odb/odb-mysql libs into our project. Persist is already working, but we have trouble while loading the objects. We always get a odb::object_not_persistent error with most of our objects, only very simple objects can be loaded. How can we find out what is going wrong? Best regards, Andreas From boris at codesynthesis.com Tue Jul 5 09:26:15 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 5 09:28:56 2011 Subject: [odb-users] Object not persistent In-Reply-To: <4E130BAD.9040906@informatik.uni-tuebingen.de> References: <4E130BAD.9040906@informatik.uni-tuebingen.de> Message-ID: Hi Andreas, Andreas Gerasch writes: > Persist is already working, but we have trouble while loading the > objects. We always get a odb::object_not_persistent error with most of > our objects, only very simple objects can be loaded. > > How can we find out what is going wrong? I assume you are using the load() function to load an object given its id. There are two things that determine what will be loaded (and whether it will be found) when using this function: 1. Object type. This is what you specify in <> brackets after load, as in "load (1);". The type determines the table in which ODB will look for the object. 2. Object id. This is the argument you pass to the load() function. Both of these parameters have to be correct. If you think that the object is in the database but load() still fails, then I suggest that you connect to the database using the mysql client and see if the object is indeed there. For example, you could run a query like this: select * from person where id = 1; Here 'person' is the name of the table where the person objects are stored (normally just the class name) and 'id' is the name of the column that is the primary key (normally the name of the data member designated as object id). If this still does not help (i.e., you see the object in the database but load() still fails), then I would need a small test case that reproduces this problem. Boris From gerasch at informatik.uni-tuebingen.de Tue Jul 5 10:59:37 2011 From: gerasch at informatik.uni-tuebingen.de (Andreas Gerasch) Date: Tue Jul 5 10:59:44 2011 Subject: [odb-users] Object not persistent In-Reply-To: References: <4E130BAD.9040906@informatik.uni-tuebingen.de> Message-ID: <4E1326D9.3060308@informatik.uni-tuebingen.de> Hi Boris, thanks for your fast reply. We now figured out, that links (we use raw pointers) between our objects are not correct in the database, they just point to random numbers. So, something went wrong during the persist process. Is there something special when using raw pointers? Thanks a lot, Andreas On 07/05/2011 03:26 PM, Boris Kolpackov wrote: > Hi Andreas, > > Andreas Gerasch writes: > >> Persist is already working, but we have trouble while loading the >> objects. We always get a odb::object_not_persistent error with most of >> our objects, only very simple objects can be loaded. >> >> How can we find out what is going wrong? > > I assume you are using the load() function to load an object given > its id. There are two things that determine what will be loaded > (and whether it will be found) when using this function: > > 1. Object type. This is what you specify in<> brackets after > load, as in "load (1);". The type determines the > table in which ODB will look for the object. > > 2. Object id. This is the argument you pass to the load() function. > > Both of these parameters have to be correct. If you think that the > object is in the database but load() still fails, then I suggest > that you connect to the database using the mysql client and see > if the object is indeed there. For example, you could run a > query like this: > > select * from person where id = 1; > > Here 'person' is the name of the table where the person objects > are stored (normally just the class name) and 'id' is the name > of the column that is the primary key (normally the name of the > data member designated as object id). > > If this still does not help (i.e., you see the object in the > database but load() still fails), then I would need a small test > case that reproduces this problem. > > Boris -- Dipl.-inform. Andreas Gerasch Arbeitsbereich Algorithmik Prof. Michael Kaufmann Mathematisch-Naturwissenschaftliche Fakult?t Fachbereich Informatik (Wilhelm-Schickard-Institut) Universit?t T?bingen Sand 13, Raum B113 72076 T?bingen +49 7071 29 70484 +49 173 979 2247 (mobil) From boris at codesynthesis.com Wed Jul 6 03:59:10 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 6 04:01:51 2011 Subject: [odb-users] Object not persistent In-Reply-To: <4E1326D9.3060308@informatik.uni-tuebingen.de> References: <4E130BAD.9040906@informatik.uni-tuebingen.de> <4E1326D9.3060308@informatik.uni-tuebingen.de> Message-ID: Hi Andreas, Andreas Gerasch writes: > We now figured out, that links (we use raw pointers) between our objects > are not correct in the database, they just point to random numbers. > > So, something went wrong during the persist process. Is there something > special when using raw pointers? There is nothing special about using raw pointers but there are some tricky areas when persisting object references. First of all, all the objects have to be persisted individually. There is no automatic persisting of pointed-to objects. So if you have: #pragma db object class employer { #pragma db id unsigned int id; }; #pragma db object class employee { #pragma db id unsigned int id; employer* er; }; Then the persist transaction might look like this: employer er; er.id = 1; employee ee; ee.id = 1; ee.er = &er; db->persist (ee); db->persist (er); In this particular case it does not matter in which order you persist the object as long as you have assigned their object ids before calling persist(). When the persist() function saves the employee object in the database, it obtains the object id of the employer that is pointed-to by er. If this object id is not yet initialized, then bad things will happen, as in this transaction: employer er; employee ee; ee.er = &er; ee.id = 1; db->persist (ee); // Bad: ee.er->id is garbage er.id = 1; db->persist (er); The order of the persist () calls becomes important if you are using automatically-assigned object ids (in the above example we used manually- assigned ids). In this case, because the id is assigned by the database during the persist() call, we must serialize the objects in the correct order, which is pointed-to object (employer) first and pointing object (employee) second. For example: #pragma db object class employer { #pragma db id auto unsigned int id; }; #pragma db object class employee { #pragma db id auto unsigned int id; employer* er; }; employer er; employee ee; ee.er = &er; db->persist (er); // Assigns er.id db->persist (ee); // Uses ee.er->id Boris From gerasch at informatik.uni-tuebingen.de Wed Jul 6 04:26:14 2011 From: gerasch at informatik.uni-tuebingen.de (Andreas Gerasch) Date: Wed Jul 6 04:26:24 2011 Subject: [odb-users] Object not persistent In-Reply-To: References: <4E130BAD.9040906@informatik.uni-tuebingen.de> <4E1326D9.3060308@informatik.uni-tuebingen.de> Message-ID: <4E141C26.9030206@informatik.uni-tuebingen.de> Hi Boris, > The order of the persist () calls becomes important if you are using > automatically-assigned object ids (in the above example we used manually- > assigned ids). In this case, because the id is assigned by the database > during the persist() call, we must serialize the objects in the correct > order, which is pointed-to object (employer) first and pointing object > (employee) second. For example: okay, this the problem. We thought, ids are automatically assigned to referenced objects, if not already existing. Would it be possible to introduce this feature in future? Is it possible to have bi-directional dependencies and auto ids working together? Thanks a lot, Andreas > > #pragma db object > class employer > { > #pragma db id auto > unsigned int id; > }; > > #pragma db object > class employee > { > #pragma db id auto > unsigned int id; > > employer* er; > }; > > employer er; > employee ee; > ee.er =&er; > > db->persist (er); // Assigns er.id > db->persist (ee); // Uses ee.er->id > > Boris -- Dipl.-inform. Andreas Gerasch Arbeitsbereich Algorithmik Prof. Michael Kaufmann Mathematisch-Naturwissenschaftliche Fakult?t Fachbereich Informatik (Wilhelm-Schickard-Institut) Universit?t T?bingen Sand 13, Raum B113 72076 T?bingen +49 7071 29 70484 +49 173 979 2247 (mobil) From boris at codesynthesis.com Wed Jul 6 04:50:40 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 6 04:53:18 2011 Subject: [odb-users] Object not persistent In-Reply-To: <4E141C26.9030206@informatik.uni-tuebingen.de> References: <4E130BAD.9040906@informatik.uni-tuebingen.de> <4E1326D9.3060308@informatik.uni-tuebingen.de> <4E141C26.9030206@informatik.uni-tuebingen.de> Message-ID: Hi Andreas, Andreas Gerasch writes: > okay, this the problem. We thought, ids are automatically assigned to > referenced objects, if not already existing. > > Would it be possible to introduce this feature in future? I am not sure it is possible to implement something like this. An id is assigned (by the database) when the object is persisted (a row is inserted into the database). So persisting of an object and assigning of an id always go together. Some databases have a concept of sequences in which case it is theoretically possible to first ask for an id and then serialize the object. But that would make it less efficient since we will need to perform a SELECT and an INSERT instead of just the INSERT. Plus, it is generally impossible for ODB to know whether the value in the id member is garbage (the object hasn't yet been persisted) or is valid. We would need some help from the object, for example, by requesting that all "uninitialized" ids be initialized to 0. A better way to resolve this would probably be to automatically persist all referenced objects. For this to work without the above requirement (initialization of the id member to 0) one would have to use a session which keeps track of all the persistent objects. > Is it possible to have bi-directional dependencies and auto ids working > together? Yes, if both sides of the relationship have auto ids, then this gets a bit tricky. If one side is inverse (which should be the case almost always), then you first persist the inverse side and then the direct one. If there is no inverse side, then you will need to use an update() call after persist to set the correct object id on one of the objects. Boris From gerasch at informatik.uni-tuebingen.de Wed Jul 6 05:13:45 2011 From: gerasch at informatik.uni-tuebingen.de (Andreas Gerasch) Date: Wed Jul 6 05:13:54 2011 Subject: [odb-users] Object not persistent In-Reply-To: References: <4E130BAD.9040906@informatik.uni-tuebingen.de> <4E1326D9.3060308@informatik.uni-tuebingen.de> <4E141C26.9030206@informatik.uni-tuebingen.de> Message-ID: <4E142749.3070203@informatik.uni-tuebingen.de> Hi Boris, > I am not sure it is possible to implement something like this. An id > is assigned (by the database) when the object is persisted (a row is > inserted into the database). So persisting of an object and assigning > of an id always go together. Some databases have a concept of sequences > in which case it is theoretically possible to first ask for an id and > then serialize the object. But that would make it less efficient since > we will need to perform a SELECT and an INSERT instead of just the INSERT. I think, it would be possible, if you do this in the commit method. So the persist(..) function creates the database row and assigns the auto id to the object. You collect all objects which have been persisted in this transaction and "persist" them a second time, where you update all references. Andreas From kuentzer at googlemail.com Thu Jul 7 11:17:59 2011 From: kuentzer at googlemail.com (Jan Kuentzer) Date: Thu Jul 7 13:20:55 2011 Subject: [odb-users] Inheritance Message-ID: Hi Boris, I am facing some problems concerning inheritance and hope that I only missed something. We have some data structure like the following: class employee {...} class permanent_employee: public employee {...} class temporary_employee: public employee {...} class company { std::vector employees; } If we generate with ODB the sql each class get it's own table and the vector is associated with employee ids. But the stored objects are sometimes instances of permanent_employee, temporary_employee or employee. Therefore the object ids are not correct in the database since for queries ODB always searches for the corresponding entries in employee, where they cannot be found (it is stored in the derived class tables) Did I understand something wrong and there is a workaround for that? Or is this what you meant with chapter 8.2 which will come in the future? Thanks for you help! Best Jan From boris at codesynthesis.com Fri Jul 8 04:52:01 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 8 04:54:39 2011 Subject: [odb-users] Inheritance In-Reply-To: References: Message-ID: Hi Jan, Jan Kuentzer writes: > I am facing some problems concerning inheritance and hope that I only missed > something. We have some data structure like the following: > > class employee > {...} > > class permanent_employee: public employee > {...} > > class temporary_employee: public employee > {...} > > class company > { > std::vector employees; > } > > If we generate with ODB the sql each class get it's own table and the vector > is associated with employee ids. But the stored objects are sometimes > instances of permanent_employee, temporary_employee or employee. > Therefore the object ids are not correct in the database since for queries > ODB always searches for the corresponding entries in employee, where they > cannot be found (it is stored in the derived class tables) > Did I understand something wrong and there is a workaround for that? Or is > this what you meant with chapter 8.2 which will come in the future? Yes, this is an example of polymorphic inheritance which is still on the TODO list. There are generally three different approaches to modeling polymorphic inheritance in the database: 1. Table per hierarchy, where all derived objects belonging to a hierarchy are stored in a single table. 2. Table per difference, where additional columns corresponding to the derived classes are stored in additional tables. 3. Table per class, where each class in a hierarchy gets its own independent table that contains all its members. The first approach is the most inflexible: you have to provide the so- called discriminator (basically a value that distinguishes different classes) and the whole hierarchy must reside in a single header. But it is also the fastest. The second and third approaches are more flexible but are generally not as efficient as the first one. Do you have any preference as to which approach would work best in your case? There is also a way to emulate polymorphic inheritance for the time being that will work well with load() and object relationships but won't handle queries. Let me know if you would be interested in this and I will elaborate. Boris From jan.kuentzer at roche.com Fri Jul 8 08:20:49 2011 From: jan.kuentzer at roche.com (Kuentzer, Jan) Date: Fri Jul 8 08:20:56 2011 Subject: [odb-users] Inheritance In-Reply-To: <38307BF0D71C2644BDA445BF0AFED3654DC197AA4F@mx1> References: <38307BF0D71C2644BDA445BF0AFED3654DC197AA4F@mx1> Message-ID: <24FA8A6483D7144F8D95F61A94417815049CCAA896@RKAMSEM705.emea.roche.com> Hi Boris, Thanks for the fast reply ! > Yes, this is an example of polymorphic inheritance which is still on the TODO list. There are generally three different approaches to modeling polymorphic inheritance in the database: > > 1. Table per hierarchy, where all derived objects belonging to a hierarchy > are stored in a single table. > > 2. Table per difference, where additional columns corresponding to the > derived classes are stored in additional tables. > > 3. Table per class, where each class in a hierarchy gets its own > independent table that contains all its members. > > The first approach is the most inflexible: you have to provide the so- called discriminator (basically a value that distinguishes different > classes) and the whole hierarchy must reside in a single header. But it is also the fastest. > > The second and third approaches are more flexible but are generally not as efficient as the first one. > > Do you have any preference as to which approach would work best in your case? I would think the third (or second) should work fine, since this would result in no change of the kernel classes. However, I cannot image how the performance difference would be? Should be still okay for us I guess. The question is after a query do you get the example objects as instance of permanent_employee or only employee? We would need to know the type of the class. > > There is also a way to emulate polymorphic inheritance for the time being that will work well with load() and object relationships but won't handle queries. Let me know if you would be interested in this and I will elaborate. If there is a emulation I would be interested since I like your project and it would save me a lot of time and effort. But I rely on the predefined data model based on the polymorphic inheritance. For the time being the load() would be okay and I could add queries as soon as ODB supports polymorphic inheritance. Thanks for the help and this really nice project! Best Jan From boris at codesynthesis.com Fri Jul 8 10:15:14 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 8 10:17:54 2011 Subject: [odb-users] Inheritance In-Reply-To: <24FA8A6483D7144F8D95F61A94417815049CCAA896@RKAMSEM705.emea.roche.com> References: <38307BF0D71C2644BDA445BF0AFED3654DC197AA4F@mx1> <24FA8A6483D7144F8D95F61A94417815049CCAA896@RKAMSEM705.emea.roche.com> Message-ID: Hi Jan, Kuentzer, Jan writes: > I would think the third (or second) should work fine, since this would > result in no change of the kernel classes. The first approach doesn't really require changes to the base classes. Underneath the ORM layer, however, all these classes are mapped to a single table, so when you add a new derived class, that table has to be extended with additional columns. > However, I cannot image how the performance difference would be? With the first approach (single table per hierarchy), all the operations (load, update, query, etc) will require a single statement (select, update, etc). With the second approach, the load/query operations can be implemented only as several queries or using joins, both of which are more expensive than a single simple query. For update, we will always need several update statements. With the third approach the load/query operations are even more complex/expensive while update goes back to a single statement. > The question is after a query do you get the example objects as instance > of permanent_employee or only employee? We would need to know the type > of the class. When polymorphic inheritance is implemented, if you do load (or query) like this: employee* e = db->query (2); And the actual object corresponding to id 2 is permanent_employee, you will get a dynamic instance of permanent_employee as an employee pointer. You will then be able to discover the dynamic type of the object at runtime, for example: if (permanent_employee* pe = dynamic_cast (e)) { // We have a permanent employee. } else if (temporary_employee* pe = dynamic_cast (e)) { // We have a temporary employee. } else { // Some other employee. } > If there is a emulation I would be interested since I like your project > and it would save me a lot of time and effort. But I rely on the predefined > data model based on the polymorphic inheritance. For the time being the > load() would be okay and I could add queries as soon as ODB supports > polymorphic inheritance. The idea behind emulation is to encode the object type into the id. This way, when you load the object, you can first figure out its actual type and then load it from the database. In this approach you cannot use the automatically-assigned ids for the hierarchy, and all objects in the hierarchy must share the same id space. As an example, let's use a 64-bit integer as an id for our employee hierarchy. To encode the object type, we will reserve the top byte and will use 1 for permanent_employee and 2 for temporary_employee (employee class is abstract and doesn't need a type code). #pragma db object abstract class employee { public: ... unsigned long long id () const { return id_; } protected: friend class odb::access; employee () {} // Default c-tor for ODB. // C-tor for derived types. // employee (unsigned char type_code, unsigned long long id) { id = (type_code << 56) | (id & 0x00FFFFFFFFFFFFFFUL); } #pragma db id unsigned long long id_; }; #pragma db object class permanent_employee { public: permanent_employee (unsigned long long id) : employee (1 /* type code for permanent_employee */, id) { } ... }; #pragma db object class temporary_employee { public: temporary_employee (unsigned long long id) : employee (2 /* type code for temporary_employee */, id) { } ... }; Next we need to wrap the database operation with some extra logic. Here is polymorphic persist: unsigned long long persist_employee (odb::database& db, employee* e) { switch (d->id () >> 56) // Get the type code. { case 1: return db->persist (static_cast (e)); case 2: return db->persist (static_cast (e)); default: assert (false); } }; And here is polymorphic load() (note that id should be what's returned by the persist() call or what's stored in employee::id_, not what we pass to *_employee constructors). employee* load_employee (odb::database& db, unsigned long long id) { switch (id >> 56) // Get the type code. { case 1: return db->load (id); case 2: return db->load (id); default: assert (false); } } Finally, in order to have a polymorphic object relationship, you will need to emulate it by having a persistent member that is the object id and a transient member which is the actual pointer: #pragma db object class employer { ... unsigned long long ceo_id_; #pragma db transient employee* ceo_; }; You will then need to use the load_employee() function to load the ceo_ pointer. For the next release of ODB we have added support for user callbacks. This feature will allow you to handle such loading transparently. Boris From pena.rd at gmail.com Sat Jul 9 15:16:34 2011 From: pena.rd at gmail.com (Rafael Pena) Date: Sat Jul 9 15:16:42 2011 Subject: [odb-users] Many-to-many adding values to join table. Message-ID: I am a bit confused about the many-to-many relationship. How do I add the relationship when when both entities already exist? These are my classes: class PartData { public: PartData(const PartData& orig); virtual ~PartData(); private: PartData() { } friend class odb::access; #pragma db id auto //other fields go here unsigned long partdataid; #pragma db not_null inverse(parts) std::vector > tests; }; class TestData { public: TestData(long testnum); TestData(const TestData& orig); virtual ~TestData(); private: TestData() { } friend class odb::access; #pragma db id auto unsigned long testdataid; //other fields go here #pragma db not_null unordered std::vector > parts; }; When both already exist and I add one (parts.push_back()) to the other. How do I add to the join table? I tried update and persist but neither added the value to the table. I am confused. Anybody have an example? I looked through the docs but I can't find any details. Right now I am just running an insert query: db->execute("insert into TestData_parts values (" + testid+","+ partdataids.str() + ")"); Although it works, is there another way to do it? David From grafl at datatrans.hu Sat Jul 9 15:26:02 2011 From: grafl at datatrans.hu (=?UTF-8?Q?Graf_L=C3=A1szl=C3=B3?=) Date: Sat Jul 9 15:26:11 2011 Subject: [odb-users] Build odb on win32 Message-ID: Hi all, I would like to build the odb packages on windows xp sp3 using vs2008. I red the documentation about this topic on your site and I found these lines: "In order to build ODB source packages you will need Microsoft Visual Studio 2008 (VC++ 9.0) or later. You will also most likely need a client library for the database system of your choice. For example, for MySQL you need the libmysqlclient library. The INSTALL file accompanying each database runtime library has more information on the database-specific prerequisites." OK, I have the vs2008 but after creating the solution and the odb project but during the compile process I get these errors below. Where can I find the cutl library or other missing files? Thank you, grafl 1>------ Build started: Project: odb, Configuration: Release Win32 ------ 1>Compiling... 1>unit.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>union.cxx 1>.\odb\odb\semantics\union.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>union-template.cxx 1>.\odb\odb\semantics\union-template.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>template.cxx 1>.\odb\odb\semantics\template.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>namespace.cxx 1>.\odb\odb\semantics\namespace.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>fundamental.cxx 1>.\odb\odb\semantics\fundamental.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>enum.cxx 1>.\odb\odb\semantics\enum.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>elements.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>derived.cxx 1>.\odb\odb\semantics\derived.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>class.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>class-template.cxx 1>.\odb\odb\semantics\class-template.cxx(6) : fatal error C1083: Cannot open include file: 'cutl/compiler/type-info.hxx': No such file or directory 1>type-processor.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>source.cxx 1>F:\src\c_cpp\odb\odb\odb/context.hxx(18) : fatal error C1083: Cannot open include file: 'cutl/re.hxx': No such file or directory 1>schema.cxx 1>F:\src\c_cpp\odb\odb\odb/context.hxx(18) : fatal error C1083: Cannot open include file: 'cutl/re.hxx': No such file or directory 1>validator.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>profile.cxx 1>.\odb\odb\profile.cxx(6) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory 1>pragma.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>plugin.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>parser.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>option-types.cxx 1>.\odb\odb\option-types.cxx(39) : error C2061: syntax error : identifier 'database_' 1>.\odb\odb\option-types.cxx(39) : error C2059: syntax error : ')' 1>.\odb\odb\option-types.cxx(39) : error C2143: syntax error : missing ')' before ';' 1>.\odb\odb\option-types.cxx(40) : error C2061: syntax error : identifier 'lower_bound' 1>.\odb\odb\option-types.cxx(40) : error C2059: syntax error : ')' 1>.\odb\odb\option-types.cxx(40) : error C2143: syntax error : missing ')' before ';' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not deduce template argument for 'const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iterator(266) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(90) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2782: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : template parameter '_Elem' is ambiguous 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(80) : see declaration of 'std::operator ==' 1> could be 'char' 1> or 'const char **(void)' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(70) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\streambuf(548) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(173) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2220) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2024) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\utility(68) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(42) : error C2677: binary '==' : no global operator found which takes type 'std::string' (or there is no acceptable conversion) 1>.\odb\odb\option-types.cxx(43) : error C2296: '-' : illegal, left operand has type 'const char **(__cdecl *)(void)' 1>.\odb\odb\option-types.cxx(43) : error C2514: 'database::value' : class has no constructors 1> F:\src\c_cpp\odb\odb\odb/option-types.hxx(14) : see declaration of 'database::value' 1>.\odb\odb\option-types.cxx(79) : error C2061: syntax error : identifier 'schema_format_' 1>.\odb\odb\option-types.cxx(79) : error C2059: syntax error : ')' 1>.\odb\odb\option-types.cxx(79) : error C2143: syntax error : missing ')' before ';' 1>.\odb\odb\option-types.cxx(80) : error C2061: syntax error : identifier 'lower_bound' 1>.\odb\odb\option-types.cxx(80) : error C2059: syntax error : ')' 1>.\odb\odb\option-types.cxx(80) : error C2143: syntax error : missing ')' before ';' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not deduce template argument for 'const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iterator(266) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(90) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2782: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : template parameter '_Elem' is ambiguous 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(80) : see declaration of 'std::operator ==' 1> could be 'char' 1> or 'const char **(void)' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(70) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\streambuf(548) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(173) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2220) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2024) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const char **(void)' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\utility(68) : see declaration of 'std::operator ==' 1>.\odb\odb\option-types.cxx(82) : error C2677: binary '==' : no global operator found which takes type 'std::string' (or there is no acceptable conversion) 1>.\odb\odb\option-types.cxx(83) : error C2296: '-' : illegal, left operand has type 'const char **(__cdecl *)(void)' 1>.\odb\odb\option-types.cxx(83) : error C2514: 'schema_format::value' : class has no constructors 1> F:\src\c_cpp\odb\odb\odb/option-types.hxx(44) : see declaration of 'schema_format::value' 1>Compiling... 1>option-functions.cxx 1>F:\src\c_cpp\odb\odb\odb/option-functions.hxx(9) : fatal error C1083: Cannot open include file: 'odb/options.hxx': No such file or directory 1>odb.cxx 1>.\odb\odb\odb.cxx(9) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory 1>inline.cxx 1>F:\src\c_cpp\odb\odb\odb/context.hxx(18) : fatal error C1083: Cannot open include file: 'cutl/re.hxx': No such file or directory 1>include.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>header.cxx 1>F:\src\c_cpp\odb\odb\odb/context.hxx(18) : fatal error C1083: Cannot open include file: 'cutl/re.hxx': No such file or directory 1>generator.cxx 1>.\odb\odb\generator.cxx(12) : fatal error C1083: Cannot open include file: 'cutl/fs/auto-remove.hxx': No such file or directory 1>error.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>emitter.cxx 1>F:\src\c_cpp\odb\odb\odb/context.hxx(18) : fatal error C1083: Cannot open include file: 'cutl/re.hxx': No such file or directory 1>cxx-lexer.cxx 1>F:\src\c_cpp\odb\odb\odb/gcc.hxx(16) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory 1>context.cxx 1>F:\src\c_cpp\odb\odb\odb/context.hxx(18) : fatal error C1083: Cannot open include file: 'cutl/re.hxx': No such file or directory 1>common.cxx 1>.\odb\odb\relational\common.cxx(10) : fatal error C1083: Cannot open include file: 'cxxabi.h': No such file or directory 1>Build log was saved at "file://f:\src\c_cpp\odb\Release\BuildLog.htm" 1>odb - 66 error(s), 0 warning(s) From boris at codesynthesis.com Sat Jul 9 15:42:16 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat Jul 9 15:44:56 2011 Subject: [odb-users] Many-to-many adding values to join table. In-Reply-To: References: Message-ID: Hi Rafael, Rafael Pena writes: > I am a bit confused about the many-to-many relationship. How do I add the > relationship when when both entities already exist? > These are my classes: > > class PartData { > > [...] > > #pragma db id auto > //other fields go here > > unsigned long partdataid; > > #pragma db not_null inverse(parts) > std::vector > tests; > }; > > class TestData { > > [...] > > #pragma db id auto > unsigned long testdataid; > //other fields go here > #pragma db not_null unordered > std::vector > parts; > }; > > When both already exist and I add one (parts.push_back()) to the other. How > do I add to the join table? You will need to modify the direct (non-inverse) object (TestData) and update its state in the database, for example: shared_ptr pd = ...; // Already persisted object. shared_ptr td = ...; // Already persisted object. td->parts.push_back (pd); db->update (td); You should probably also update the non-inverse side so that your in-memory model is consistent. > Anybody have an example? The example that shows how to work with bi-directional relationships is called 'inverse'. > Right now I am just running an insert query: > > db->execute("insert into TestData_parts values (" + testid+","+ > partdataids.str() + ")"); No, this is definitely not the way to do it. Boris From boris at codesynthesis.com Sat Jul 9 15:49:14 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat Jul 9 15:51:54 2011 Subject: [odb-users] Build odb on win32 In-Reply-To: References: Message-ID: Hi Graf, Graf L?szl? writes: > I would like to build the odb packages on windows xp sp3 > using vs2008. I red the documentation about this topic on > your site and I found these lines: > > "In order to build ODB source packages you will need Microsoft > Visual Studio 2008 (VC++ 9.0) or later. You will also most > likely need a client library for the database system of your > choice. For example, for MySQL you need the libmysqlclient > library. The INSTALL file accompanying each database runtime > library has more information on the database-specific > prerequisites." > > OK, I have the vs2008 but after creating the solution and > the odb project but during the compile process I get these errors below. > Where can I find the cutl library or other missing files? The above instructions are for building the ODB runtime libraries (libodb and libodb-) on Windows using Visual Studio 2008. From your build log I see that you are trying to build the ODB compiler itself. Underneath the ODB compiler is implemented as GCC plugin and it cannot be built with VC++. In fact building the ODB compiler for Windows is quite a complicated process (it is built as custom MinGW toolchain). Because of that, we provide a pre-built ODB compiler distribution (called odb-.x.y.z-i686-windows) which can be used out of the box (you will still need to build the runtime libraries mentioned above with your version of VC++). Boris From losintikfos at yahoo.co.uk Sun Jul 10 15:12:45 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Mon Jul 11 05:01:02 2011 Subject: [odb-users] ODB with eclipse In-Reply-To: Message-ID: <1310325165.47508.YahooMailClassic@web29301.mail.ird.yahoo.com> Hello guys, I am trying to generate my persistence class using eclipse. I have done this with netbeans and it works like a charm. When i try it using eclipse by right clicking the person.h file and select properties -> C++ Build -> Settings and then add the command and the outputs, I end up with this error when i try clean or build to generate the classes. education.h: error: unable to open in read mode make: *** [src/education-odb.hxx] Error 1 Does this means I cannot do it via eclipse? Thanks From jan.kuentzer at roche.com Mon Jul 11 05:54:35 2011 From: jan.kuentzer at roche.com (Kuentzer, Jan) Date: Mon Jul 11 05:54:43 2011 Subject: [odb-users] Inheritance In-Reply-To: References: <38307BF0D71C2644BDA445BF0AFED3654DC197AA4F@mx1> <24FA8A6483D7144F8D95F61A94417815049CCAA896@RKAMSEM705.emea.roche.com> Message-ID: <24FA8A6483D7144F8D95F61A94417815049CCAAACF@RKAMSEM705.emea.roche.com> Hi Boris, > The first approach doesn't really require changes to the base classes. > Underneath the ORM layer, however, all these classes are mapped to a single table, > so when you add a new derived class, that table has to be extended with > additional columns. > With the first approach (single table per hierarchy), all the operations (load, update, > query, etc) will require a single statement (select, update, etc). With the second > approach, the load/query operations can be implemented only as several queries > or using joins, both of which are more expensive than a single simple query. For > update, we will always need several update statements. With the third approach the > load/query operations are even more complex/expensive while update goes back > to a single statement. Okay I misunderstood. If the first approach does not require any change to the base classes I guess the first approach with the single tables would be the one I would use since it is the fastest. > The idea behind emulation is to encode the object type into the id. This > way, when you load the object, you can first figure out its actual type > and then load it from the database. In this approach you cannot use the > automatically-assigned ids for the hierarchy, and all objects in the > hierarchy must share the same id space. > Finally, in order to have a polymorphic object relationship, you will > need to emulate it by having a persistent member that is the object > id and a transient member which is the actual pointer: > > #pragma db object > class employer > { > ... > > unsigned long long ceo_id_; > > #pragma db transient > employee* ceo_; > }; > > You will then need to use the load_employee() function to load the ceo_ > pointer. For the next release of ODB we have added support for user > callbacks. This feature will allow you to handle such loading > transparently. Okay, I understand the idea. We already have an attribute with an id we can easily change to contain the type as you suggested. The additional object id and the transient pointer are necessary because the pointer would be loaded as an employee by ODB? If I load an object with vector I will have to load all of them recursively. You said the next release will support polymorphic object relationship and/or transparent loading. Can you already say when you plan to release the next version? A few weeks or next year? Thanks Jan From boris at codesynthesis.com Mon Jul 11 07:37:24 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 11 07:40:05 2011 Subject: [odb-users] Inheritance In-Reply-To: <24FA8A6483D7144F8D95F61A94417815049CCAAACF@RKAMSEM705.emea.roche.com> References: <38307BF0D71C2644BDA445BF0AFED3654DC197AA4F@mx1> <24FA8A6483D7144F8D95F61A94417815049CCAA896@RKAMSEM705.emea.roche.com> <24FA8A6483D7144F8D95F61A94417815049CCAAACF@RKAMSEM705.emea.roche.com> Message-ID: Hi Jan, Kuentzer, Jan writes: > > You will then need to use the load_employee() function to load the ceo_ > > pointer. For the next release of ODB we have added support for user > > callbacks. This feature will allow you to handle such loading > > transparently. > > [...] The additional object id and the transient pointer are necessary > because the pointer would be loaded as an employee by ODB? Yes, that's correct. If you use the standard ODB behavior, then it will always try to load employee regardless of the actual type. > You said the next release will support polymorphic object relationship > and/or transparent loading. No, I never said the next release will support polymorphic inheritance or polymorphic object relationships. The next release will support use callbacks which will allow you to load a pointer to employee (or vector of such pointers) polymorphically and transparently using the "type code + id" method I described in my previous email. > Can you already say when you plan to release the next version? A > few weeks or next year? ODB 1.5.0 should be out in a few weeks. Boris From boris at codesynthesis.com Mon Jul 11 10:33:27 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 11 10:36:07 2011 Subject: [odb-users] ODB with eclipse In-Reply-To: <1310325165.47508.YahooMailClassic@web29301.mail.ird.yahoo.com> References: <1310325165.47508.YahooMailClassic@web29301.mail.ird.yahoo.com> Message-ID: Hi, Bright Dadson writes: > I am trying to generate my persistence class using eclipse. I have done > this with netbeans and it works like a charm. When i try it using eclipse > by right clicking the person.h file and select properties -> C++ Build -> > Settings and then add the command and the outputs, > > I end up with this error when i try clean or build to generate the classes. > > education.h: error: unable to open in read mode > make: *** [src/education-odb.hxx] Error 1 I have adapted the XSD Eclipse instructions for ODB. I haven't tried them myself thought. Can you give this a try and confirm whether it works for you? http://wiki.codesynthesis.com/Using_ODB_with_Eclipse_CDT Boris From losintikfos at yahoo.co.uk Mon Jul 11 17:51:30 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Tue Jul 12 07:02:40 2011 Subject: [odb-users] ODB with eclipse In-Reply-To: Message-ID: <1310421090.27303.YahooMailClassic@web29307.mail.ird.yahoo.com> Hi, I have tried this but still ends up with the error: I have updated my odb to 1.4 yet no joy. I am still researching on the causes - I will inform if it works. Currently this is the error: make ../education-odb.hxx Building file: ../src/education.h Compiling education.h using odb /usr/local/odb-1.4.0/bin/odb -d mysql --default-pointer std::tr1::shared_ptr --generate-query ../education.h ../education.h: error: unable to open in read mode make: *** [../education-odb.hxx] Error 1 Bright Dadson? writes: > I am trying to generate my persistence class using eclipse. I have done > this with netbeans and it works like a charm. When i try it using eclipse > by right clicking the person.h file and select properties -> C++ Build -> > Settings and then add the command and the outputs, > > I end up with this error when i try clean or build to generate the classes. > > education.h: error: unable to open in read mode > make: *** [src/education-odb.hxx] Error 1 I have adapted the XSD Eclipse instructions for ODB. I haven't tried them myself thought. Can you give this a try and confirm whether it works for you? http://wiki.codesynthesis.com/Using_ODB_with_Eclipse_CDT Boris From losintikfos at yahoo.co.uk Mon Jul 11 18:16:25 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Tue Jul 12 07:02:40 2011 Subject: [odb-users] No such file after upgrading to 1.4.0 Message-ID: <1310422585.91736.YahooMailClassic@web29302.mail.ird.yahoo.com> I have generated persistence classes using 1.4.0. in netbeans. Everything works fine, but when I try to build the project. I get below error: /root/Documents/project/eduProj/education-odb.cxx:5:23: warning: odb/pre.hxx: No such file or directory In file included from /root/Documents/project/eduProj/education-odb.cxx:12: /root/Documents/project/eduProj/education-odb.hxx:8:27: warning: odb/version.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:11:2: error: #error ODB runtime version mismatch ???????????????? from /root/Documents/project/eduProj/education-odb.cxx:12: In file included from /root/Documents/project/eduProj/education-odb.hxx:21, /root/Documents/project/eduProj/education.h:14:24: warning: odb/core.hxx: No such file or directory In file included from /root/Documents/project/eduProj/education-odb.cxx:12: /root/Documents/project/eduProj/education-odb.hxx:27:26: warning: odb/traits.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:28:34: warning: odb/pointer-traits.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:29:38: warning: odb/tr1/pointer-traits.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:30:36: warning: odb/container-traits.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:31:26: warning: odb/result.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:33:34: warning: odb/details/buffer.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:35:33: warning: odb/mysql/version.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:36:33: warning: odb/mysql/forward.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:37:37: warning: odb/mysql/mysql-types.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:38:31: warning: odb/mysql/query.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.hxx:242:24: warning: odb/post.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:16:32: warning: odb/cache-traits.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:17:34: warning: odb/details/unused.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:18:38: warning: odb/details/shared-ptr.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:20:32: warning: odb/mysql/traits.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:21:34: warning: odb/mysql/database.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:22:37: warning: odb/mysql/transaction.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:23:36: warning: odb/mysql/connection.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:24:35: warning: odb/mysql/statement.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:25:41: warning: odb/mysql/statement-cache.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:26:43: warning: odb/mysql/object-statements.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:27:46: warning: odb/mysql/container-statements.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:28:36: warning: odb/mysql/exceptions.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:29:32: warning: odb/mysql/result.hxx: No such file or directory /root/Documents/project/eduProj/education-odb.cxx:30:30: warning: odb/mysql/enum.hxx: No such file or directory ???????????????? from /root/Documents/project/eduProj/education-odb.cxx:12: In file included from /root/Documents/project/eduProj/education-odb.hxx:21, /root/Documents/project/eduProj/education.h:24: error: ?odb? has not been declared /root/Documents/project/eduProj/education.h:24: error: friend declaration does not name a class or function In file included from /root/Documents/project/eduProj/education-odb.cxx:12: /root/Documents/project/eduProj/education-odb.hxx:45: error: ?access? is not a class or namespace /root/Documents/project/eduProj/education-odb.hxx:45: error: expected unqualified-id before ? References: <1310421090.27303.YahooMailClassic@web29307.mail.ird.yahoo.com> Message-ID: Hi, Bright Dadson writes: > make ../education-odb.hxx > Building file: ../src/education.h > Compiling education.h using odb > /usr/local/odb-1.4.0/bin/odb -d mysql --default-pointer std::tr1::shared_ptr --generate-query ../education.h > ../education.h: error: unable to open in read mode Looks like your education.h file is in ../src/, not in ../ so you may want to replace ../education.h with ../src/education.h. Boris From boris at codesynthesis.com Tue Jul 12 09:33:23 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 12 09:35:59 2011 Subject: [odb-users] No such file after upgrading to 1.4.0 In-Reply-To: <1310422585.91736.YahooMailClassic@web29302.mail.ird.yahoo.com> References: <1310422585.91736.YahooMailClassic@web29302.mail.ird.yahoo.com> Message-ID: Hi, Bright Dadson writes: > I have generated persistence classes using 1.4.0. in netbeans. > Everything works fine, but when I try to build the project. > I get below error: > > > /root/Documents/project/eduProj/education-odb.cxx:5:23: warning: odb/pre.hxx: No such file or directory Looks like your C++ compiler (g++) cannot find the libodb headers. Make sure that you installed 1.4.0 into a location where g++ looks by default (normally /usr and /usr/local). Boris From pena.rd at gmail.com Tue Jul 12 10:01:53 2011 From: pena.rd at gmail.com (Rafael Pena) Date: Tue Jul 12 10:02:01 2011 Subject: [odb-users] No such file after upgrading to 1.4.0 In-Reply-To: References: <1310422585.91736.YahooMailClassic@web29302.mail.ird.yahoo.com> Message-ID: Or make sure that that the include dir is listed in the project properties. http://imgur.com/FuxfC On Tue, Jul 12, 2011 at 9:33 AM, Boris Kolpackov wrote: > Hi, > > Bright Dadson writes: > > > I have generated persistence classes using 1.4.0. in netbeans. > > Everything works fine, but when I try to build the project. > > I get below error: > > > > > > /root/Documents/project/eduProj/education-odb.cxx:5:23: warning: > odb/pre.hxx: No such file or directory > > Looks like your C++ compiler (g++) cannot find the libodb headers. Make > sure that you installed 1.4.0 into a location where g++ looks by default > (normally /usr and /usr/local). > > Boris > > From dcoffey at netharmonix.com Wed Jul 13 15:45:48 2011 From: dcoffey at netharmonix.com (Dan Coffey) Date: Thu Jul 14 05:01:14 2011 Subject: [odb-users] Unresolved inclusion: mysql/mysqld_error.h Message-ID: <4E1DF5EC.8030203@netharmonix.com> I'm trying to build my first ODB example code for person.hxx, driver.cxx and database.hxx using per the Eclipse ODB documentation: * ODB: 1.4.0 * Windows: 32Bit XP SP3 * Eclipse: Version: Helios Service Release 2 Build id: 20110218-0911 * MySQL Server 5.5 * mingw32 4.5.2 Using Eclipse - Index - Search for unresolved includes I get this set of errors. All of these .h files exist in the include directory */C:\Program Files\MySQL\MySQL Server 5.5\include/* but not in the *include/mysql* directory This statement in mysql-types.hxx seems to be the cause, is there some place I need to configure so that this attribute (LIBODB_MYSQL_INCLUDE_SHORT) is set? I'm I missing the mysql/*.h files? If so, then do you have a link to the files I need? #ifdef LIBODB_MYSQL_INCLUDE_SHORT # include #else # include #endif ------------------------------------------------------------------------ ERROR OUTPUT from Using Eclipse - Index - Search for unresolved includes: D:/Development/C++/ODB/libodb-mysql-1.4.0/odb/mysql mysql-types.hxx Unresolved inclusion: mysql/mysql_time.h mysql.hxx Unresolved inclusion: mysql/errmsg.h Unresolved inclusion: mysql/mysql.h Unresolved inclusion: mysql/mysqld_error.h version.hxx Unresolved inclusion: mysql/mysql_version.h D:/Development/C++/ODB/libodb-mysql-1.4.0/odb/mysql/details config.hxx Unresolved inclusion: odb/mysql/details/config.h ------------------------------------------------------------------------ Thanks, Dan From boris at codesynthesis.com Thu Jul 14 06:04:38 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 14 06:07:16 2011 Subject: [odb-users] Unresolved inclusion: mysql/mysqld_error.h In-Reply-To: <4E1DF5EC.8030203@netharmonix.com> References: <4E1DF5EC.8030203@netharmonix.com> Message-ID: Hi Dan, Dan Coffey writes: > This statement in mysql-types.hxx seems to be the cause, is there some > place I need to configure so that this attribute > (LIBODB_MYSQL_INCLUDE_SHORT) is set? This macro is defined in the config.h file in libodb-mysql in odb/mysql/details/ which, according to your email you don't have. This tells me that you haven't built the libodb-mysql runtime. Before you can build any examples, you need to build libodb and libodb-mysql. To build libodb-mysql for MinGW you will need the MySQL client library. You can use the headers and the library that came with the MySQL package, however, you will need to rename libmysql.lib to libmysqlclient_r.a. I also suggest that you get rid of spaces in your paths; it will make your life much easier. Boris From dcoffey at netharmonix.com Thu Jul 14 11:06:35 2011 From: dcoffey at netharmonix.com (Dan Coffey) Date: Thu Jul 14 13:21:13 2011 Subject: [odb-users] Unresolved inclusion: mysql/mysqld_error.h In-Reply-To: References: <4E1DF5EC.8030203@netharmonix.com> Message-ID: <4E1F05FB.6020901@netharmonix.com> Hi Boris, Thanks for the direction. I'm trying to run the configure command in the /opt/libodb-mysql directory $ *sh ./configure* I'm using Cygwin on XP and I created: symbolic links to the files /opt/libodb/include ln -s /cygdrive/d/Development/C++/ODB/odb-1.4.0-i686-windows/mingw/include /opt/libodb/include /opt/libodb/lib ln -s /cygdrive/d/Development/C++/ODB/odb-1.4.0-i686-windows/mingw/lib /opt/libodb/lib /opt/libodb-mysql ln -s /cygdrive/d/Development/C++/ODB/odb-mysql-1.4.0 /opt/libodb-mysql symbolic links to the files: /usr/local/mysql ln -s /cygdrive/d/Development/C++/DB/mysql-5.5.14.win32 /usr/local/mysql I copied and changed: mysqlclient.lib to mysqlclient_r.a When I run /opt/libodb-mysql/configure I get an error: */configure: error: cannot run /bin/sh config/config.sub/* I tried to go directly to the D:PATH, but that had the same error. I also ran it with: $ sh -xv ./configure Here is the end of that output Thanks for you help. Dan On 7/14/2011 6:04 AM, Boris Kolpackov wrote: > Hi Dan, > > Dan Coffey writes: > >> This statement in mysql-types.hxx seems to be the cause, is there some >> place I need to configure so that this attribute >> (LIBODB_MYSQL_INCLUDE_SHORT) is set? > This macro is defined in the config.h file in libodb-mysql in > odb/mysql/details/ which, according to your email you don't have. > This tells me that you haven't built the libodb-mysql runtime. > Before you can build any examples, you need to build libodb and > libodb-mysql. > > To build libodb-mysql for MinGW you will need the MySQL client > library. You can use the headers and the library that came with > the MySQL package, however, you will need to rename libmysql.lib > to libmysqlclient_r.a. I also suggest that you get rid of spaces > in your paths; it will make your life much easier. > > Boris From boris at codesynthesis.com Thu Jul 14 13:35:19 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 14 13:37:58 2011 Subject: [odb-users] Unresolved inclusion: mysql/mysqld_error.h In-Reply-To: <4E1F05FB.6020901@netharmonix.com> References: <4E1DF5EC.8030203@netharmonix.com> <4E1F05FB.6020901@netharmonix.com> Message-ID: Hi Dan, Dan Coffey writes: > I'm using Cygwin on XP In your previous email you said you are using MinGW. You cannot build a Cygwin library and then use it in a MinGW build. These are different systems. > and I created: symbolic links to the files > > [...] I don't really understand why you did this. > I copied and changed: mysqlclient.lib to mysqlclient_r.a That should be libmysql.lib, not mysqlclient.lib. > When I run /opt/libodb-mysql/configure > I get an error: > */configure: error: cannot run /bin/sh config/config.sub/* There seems to be a problem with your Cygwin setup and this mailing list is not really about how to setup Cygwin or MinGW or how to use it. Building ODB runtimes in these environments is not a trivial task, especially if you are not an experienced MinGW/Cygwin user. If you want to get started with ODB on Windows, the easiest way would be to get a copy of Visual Studio (you can get Express Edition for free) and then use the provided project/solution files to build the runtime libraries and examples. There are step-by-step instructions in the INSTALL files. Boris From losintikfos at yahoo.co.uk Mon Jul 18 17:52:14 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Tue Jul 19 03:30:06 2011 Subject: [odb-users] No such file after upgrading to 1.4.0 In-Reply-To: Message-ID: <1311025934.54092.YahooMailClassic@web29303.mail.ird.yahoo.com> Hi guys, I have tried hard to resolve this issue below for almost 4 days now, but I think I have to seek advice on this. After moving the odb 1.4.0 installation to /usr/local/include when I clean my project I get this error. Can someone tell me what I have done wrong. g++? -o"myproj"? ./src/education-odb.o ./src/myproj.o ./src/member-odb.o?? -lodb-mysql -lodb ./src/education-odb.o: In function `odb::access::object_traits::persist(odb::database&, education&)': /root/Documents/project/myproj/Debug/../src/education-odb.cxx:527: undefined reference to `odb::mysql::insert_statement::id()' ./src/education-odb.o: In function `odb::access::object_traits::query_(odb::database&, odb::access::object_traits::query_type const&, odb::mysql::object_statements&, odb::details::shared_ptr&)': /root/Documents/project/myproj/Debug/../src/education-odb.cxx:776: undefined reference to `odb::mysql::query::parameters_binding() const' ./src/member-odb.o: In function `odb::access::object_traits::persist(odb::database&, member&)': /root/Documents/project/myproj/Debug/../src/member-odb.cxx:431: undefined reference to `odb::mysql::insert_statement::id()' ./src/member-odb.o: In function `odb::access::object_traits::query_(odb::database&, odb::access::object_traits::query_type const&, odb::mysql::object_statements&, odb::details::shared_ptr&)': /root/Documents/project/myproj/Debug/../src/member-odb.cxx:680: undefined reference to `odb::mysql::query::parameters_binding() const' Or make sure that that the include dir is listed in the project properties. http://imgur.com/FuxfC > I have generated persistence classes using 1.4.0. in netbeans. > Everything works fine, but when I try to build the project. > I get below error: > > > /root/Documents/project/eduProj/education-odb.cxx:5:23: warning: odb/pre.hxx: No such file or directory Looks like your C++ compiler (g++) cannot find the libodb headers. Make sure that you installed 1.4.0 into a location where g++ looks by default (normally /usr and /usr/local). Boris From boris at codesynthesis.com Tue Jul 19 05:32:14 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 19 05:34:51 2011 Subject: [odb-users] BoostCon 2011 ODB talk Message-ID: Hi, The video for the talk called "Object-Relational Mapping with ODB and Boost" that I gave at this year's BoostCon is now available: http://blip.tv/boostcon/object-relational-mapping-with-odb-and-boost-5364825 The direct link to the .mp4 file (found in the RSS feed) is this: http://blip.tv/file/get/Boostcon-ObjectrelationalMappingWithODBAndBoost586.mp4 The slides corresponding to the talk are here: https://github.com/boostcon/2011_presentations/raw/master/thu/orm_with_odb_and_boost.pdf The first half of the talk introduces the basic concepts and workflow of the ODB system. It then continues to cover more advanced topics, including profiles (with focus on Boost), containers, composite values, object relationships, and working with database schemas. There are also interesting discussions with the audience interspersed throughout the talk. Boris From boris at codesynthesis.com Tue Jul 19 10:34:55 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 19 10:37:34 2011 Subject: [odb-users] No such file after upgrading to 1.4.0 In-Reply-To: <1311025934.54092.YahooMailClassic@web29303.mail.ird.yahoo.com> References: <1311025934.54092.YahooMailClassic@web29303.mail.ird.yahoo.com> Message-ID: Hi, What most likely happens is that you are still linking to the old libodb.so and libodb-mysql.so libraries. I suggest that you search globally on your machine for these names and make sure you have only one set that points to libodb-1.4.so and libodb-mysql-1.4.so. If you don't have the 1.4 versions of these, then you need to build and install libodb and libodb-mysql. Boris From dcoffey at netharmonix.com Tue Jul 19 13:44:02 2011 From: dcoffey at netharmonix.com (Dan Coffey) Date: Tue Jul 19 13:44:10 2011 Subject: [odb-users] Unresolved inclusion: mysql/mysqld_error.h In-Reply-To: References: <4E1DF5EC.8030203@netharmonix.com> Message-ID: <4E25C262.8020802@netharmonix.com> Hi Boris, You are correct, my cygwin install was in need of an update. Updated cygwin to latest. I then linked (ln -s ...) the packages include and libs to /usr/local/... I've been able to successfully run (using cygwin) configure, make and make install for the following: * libodb-1.4.0 * libodb-boost-1.4.0 * libodb-qt-1.4.0 I'm having a problem with the libodb-mysql-1.4.0 configure script. I installed mysql-5.5.15-win32 files and linked them to the /usr/local/lib and include dirs. I copied libmysql.lib to libmysqlclient_r.a $ ls -l /usr/local/lib/libmysqlclient* lrwxrwxrwx 1 Dan Coffey root 72 Jul 18 14:16 /usr/local/lib/libmysqlclient_r.a -> /cygdrive/d/Development/C++/DB/mysql-5.5.14-win32/lib/libmysqlclient_r.a $ ls -l /usr/local/lib/mysqlclient_r.a lrwxrwxrwx 1 Dan Coffey root 69 Jul 18 14:10 /usr/local/lib/mysqlclient_r.a -> /cygdrive/d/Development/C++/DB/mysql-5.5.14-win32/lib/mysqlclient_r.a These are the commands I executed in my cygwin env. $ ./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib/mysqlclient_r.a $ ./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib Output for both of the above commands was: ... checking for __thread keyword... yes checking for libmysqlclient_r... no configure: error: libmysqlclient_r is not found; consider using CPPFLAGS/LDFLAGS to specify its location $ ls -l /usr/local/lib/libmysqlclient* lrwxrwxrwx 1 Dan Coffey root 72 Jul 18 14:16 /usr/local/lib/libmysqlclient_r.a -> /cygdrive/d/Development/C++/DB/mysql-5.5.14-win32/lib/libmysqlclient_r.a $ ls -l /usr/local/lib/mysqlclient_r.a lrwxrwxrwx 1 Dan Coffey root 69 Jul 18 14:10 /usr/local/lib/mysqlclient_r.a -> /cygdrive/d/Development/C++/DB/mysql-5.5.14-win32/lib/mysqlclient_r.a I must be missing something in the configuration process, any idea? On: XP SP3 Thanks for you help. Dan On 7/14/2011 6:04 AM, Boris Kolpackov wrote: > Hi Dan, > > Dan Coffey writes: > >> This statement in mysql-types.hxx seems to be the cause, is there some >> place I need to configure so that this attribute >> (LIBODB_MYSQL_INCLUDE_SHORT) is set? > This macro is defined in the config.h file in libodb-mysql in > odb/mysql/details/ which, according to your email you don't have. > This tells me that you haven't built the libodb-mysql runtime. > Before you can build any examples, you need to build libodb and > libodb-mysql. > > To build libodb-mysql for MinGW you will need the MySQL client > library. You can use the headers and the library that came with > the MySQL package, however, you will need to rename libmysql.lib > to libmysqlclient_r.a. I also suggest that you get rid of spaces > in your paths; it will make your life much easier. > > Boris From boris at codesynthesis.com Tue Jul 19 14:14:08 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 19 14:16:46 2011 Subject: [odb-users] Unresolved inclusion: mysql/mysqld_error.h In-Reply-To: <4E25C262.8020802@netharmonix.com> References: <4E1DF5EC.8030203@netharmonix.com> <4E25C262.8020802@netharmonix.com> Message-ID: Hi Dan, Dan Coffey writes: > configure: error: libmysqlclient_r is not found; consider using > CPPFLAGS/LDFLAGS to specify its location To find out what's going on, you can study the config.log file; it normally has much more detailed information. My guess would be the linking to libmysqlclient_r fails because you are building a Cygwin library while libmysqlclient_r.a that you have "created" from the MySQL package is a native Win32 library that can only be using for MinGW builds (and VC++). You are trying to build ODB for MinGW, not Cygwin, right? If so, then you may want to try the -mno-cygwin GCC option which can be used to build MinGW binaries under Cygwin. That is, you will need to run configure like this: ./configure CFLAGS=-mno-cygwin CXXFLAGS=-mno-cygwin LDFLAGS=-mno-cygwin You will also need to rebuild all the other libraries with this option. Note also that while this should work, we haven't tried it. We always build and test ODB on MinGW using the native MinGW toolchain and MSYS shell. Boris From losintikfos at yahoo.co.uk Wed Jul 20 18:08:12 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Thu Jul 21 09:35:10 2011 Subject: [odb-users] How to handle date in C++ with ODB Message-ID: Can anyone share light on how to convert MySQL date with C++ primitive via ODB. Can I convert long to date and persisted as bigint - any ideas?! Thanks From boris at codesynthesis.com Thu Jul 21 09:43:47 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 21 09:46:27 2011 Subject: [odb-users] How to handle date in C++ with ODB In-Reply-To: References: Message-ID: Hi, Bright Dadson writes: > Can anyone share light on how to convert MySQL date with C++ primitive > via ODB. Can I convert long to date and persisted as bigint - any ideas?! The best way would be to use either the Boost or Qt profile library. They provide automatic mapping between boost::gregorian::date (in case of Boost) or QDate (in case of Qt) and the MySQL DATE type. See the 'boost' and 'qt' examples as well as the ODB manual for more information. Alternatively, you can map your own C++ date type to my MySQL DATE. For more information on how to do this see the 'mapping' example. Finally, you can convert your C++ date representation to some integral type (e.g., as a number of days since some predefined date) and store that in the database. Boris From dcoffey at netharmonix.com Thu Jul 21 14:30:26 2011 From: dcoffey at netharmonix.com (Dan Coffey) Date: Thu Jul 21 14:30:35 2011 Subject: [odb-users] Building libodb-qt-1.4.0 on XP Message-ID: <4E287042.6090906@netharmonix.com> Hi Boris, I started out using cygwin and I could build libodb-qt-1.4.0 and libodb-boost-1.4.0 without any problems but not the libodb-mysql-1.4.0. I did try ./configure CFLAGS=-mno-cygwin CXXFLAGS=-mno-cygwin LDFLAGS=-mno-cygwin but those flags seem to have been removed from cygwin. I've switched to MinGW Shell and I could build the libodb-1.4.0 without any problems. When I try the other libodb-boost or libodb-qt I get the /configure: error: QtCore is not found;/ message. I put the qt include files in /usr/include/qt and /usr/local/include/qt but that did not fix the problem. I've run: $ ./configure CPPFLAGS=-I/usr/include/qt, no help What am I doing wrong? Thanks, Dan ------------------------------------------------------------------------ * XP SP3 * MinGW Shell * PATHS o /d/Development/C++/ODB/libodb-qt-1.4.0 o $ ls /usr/include FlexLexer.h boost mysql odb qt4 o $ ls /usr/include/qt ActiveQt Qt Qt3Support QtCore QtDBus QtDeclarative QtDesigner QtGui QtHelp QtMeeGoGraphicsSystemHelper QtMultimedia QtNetwork QtOpenGL QtOpenVG QtScript QtScriptTools QtSql QtSvg QtTest QtUiTools QtWebKit QtXml QtXmlPatterns phonon phonon_compat o $ ls /usr/include/qt4 ActiveQt Qt Qt3Support QtCore QtDBus QtDeclarative QtDesigner QtGui QtHelp QtMeeGoGraphicsSystemHelper QtMultimedia QtNetwork QtOpenGL QtOpenVG QtScript QtScriptTools QtSql QtSvg QtTest QtUiTools QtWebKit QtXml QtXmlPatterns phonon phonon_compat o $ ls /usr/local/include/qt ActiveQt Qt Qt3Support QtCore QtDBus QtDeclarative QtDesigner QtGui QtHelp QtMeeGoGraphicsSystemHelper QtMultimedia QtNetwork QtOpenGL QtOpenVG QtScript QtScriptTools QtSql QtSvg QtTest QtUiTools QtWebKit QtXml QtXmlPatterns phonon phonon_compat o $ ls /usr/local/include/qt4 ActiveQt Qt Qt3Support QtCore QtDBus QtDeclarative QtDesigner QtGui QtHelp QtMeeGoGraphicsSystemHelper QtMultimedia QtNetwork QtOpenGL QtOpenVG QtScript QtScriptTools QtSql QtSvg QtTest QtUiTools QtWebKit QtXml QtXmlPatterns phonon phonon_compat * Commands that have been executed with the output message (see below) o $ ./configure CPPFLAGS=-I/usr/include/qt o $ ./configure CPPFLAGS=-I/usr/include/qt4 o $ ./configure CPPFLAGS=-I/usr/include/qt4/ Output: checking for pkg-config... no checking for QtCore... no configure: error: QtCore is not found; consider using CPPFLAGS/LDFLAGS to specify its location From n.albeza at gmail.com Wed Jul 20 12:02:02 2011 From: n.albeza at gmail.com (Nicolas ALBEZA) Date: Fri Jul 22 09:11:51 2011 Subject: [odb-users] NULL Fields, how do they work ? Message-ID: Hello odb-users ! I'm trying to make a field nullable, but i can't find how in the manual. Maybe it is irrelevant, but i'm not generating mysql create statements with odb, i'm doing these by hand. Regards, -- ALBEZA "Pause" Nicolas From losintikfos at yahoo.co.uk Tue Jul 19 15:16:43 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Fri Jul 22 09:12:16 2011 Subject: [odb-users] No such file after upgrading to 1.4.0 In-Reply-To: Message-ID: <1311103003.50443.YahooMailClassic@web29308.mail.ird.yahoo.com> Wow you are a star. It surely did the job. --- On Tue, 19/7/11, Boris Kolpackov References: Message-ID: Hi Nicolas, Nicolas ALBEZA writes: > I'm trying to make a field nullable, but i can't find how in the manual. For this you will need two things: 1. A C++ type that is capable of representing the special NULL value. This can be, for example, a pointer as in: #pragma db object class object { ... // NULL pointer is equivalent to the NULL value in the database. // shared_ptr str; }; Or you can create a wrapper along these lines: struct nullable_string { bool null; std::string str; }; #pragma db object class object { nullable_string str; }; 2. Once you have a type that has the notion of NULL, you will need to provide a value_traits implementation for it. For an example, take a look at the tests/mysql/types test in the odb-tests package. There is a type called string_ptr which is used to test NULL-ness. The value_traits implementation is in the traits.hxx file. Also, some of the types supported by profiles provide the notion of NULL values and these type automatically store such values as NULL in the database. Once such type QString in the Qt profile. Finally, in one of the upcoming versions we are planning to add support for the boost::optional container which has a natural mapping to a column with NULL enabled. This will make working with NULL values a much more straightforward matter if you are using Boost. Perhaps we will also provide our own version of something like this in libodb, in case you cannot use Boost for some reason. Boris From boris at codesynthesis.com Fri Jul 22 09:27:09 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 22 09:29:48 2011 Subject: [odb-users] Building libodb-qt-1.4.0 on XP In-Reply-To: <4E287042.6090906@netharmonix.com> References: <4E287042.6090906@netharmonix.com> Message-ID: Hi Dan, Dan Coffey writes: > When I try the other libodb-boost or libodb-qt I get the > /configure: error: QtCore is not found;/ message. > I put the qt include files in /usr/include/qt and /usr/local/include/qt > but that did not fix the problem. Take a look at the config.log file (search for QtCore). It will have much more detailed information about what's going on (is it an include problem?, a link issue?, something else?). Boris From n.albeza at gmail.com Fri Jul 22 09:46:47 2011 From: n.albeza at gmail.com (Nicolas ALBEZA) Date: Fri Jul 22 09:46:56 2011 Subject: [odb-users] NULL Fields, how do they work ? In-Reply-To: References: Message-ID: Thanks a lot for your help, Boris. Do you know when the version including this feature will be released ? Regards, 2011/7/22 Boris Kolpackov > Hi Nicolas, > > Nicolas ALBEZA writes: > > > I'm trying to make a field nullable, but i can't find how in the manual. > > For this you will need two things: > > 1. A C++ type that is capable of representing the special NULL value. > This can be, for example, a pointer as in: > > #pragma db object > class object > { > ... > > // NULL pointer is equivalent to the NULL value in the database. > // > shared_ptr str; > }; > > Or you can create a wrapper along these lines: > > struct nullable_string > { > bool null; > std::string str; > }; > > #pragma db object > class object > { > nullable_string str; > }; > > 2. Once you have a type that has the notion of NULL, you will need > to provide a value_traits implementation for it. For an example, > take a look at the tests/mysql/types test in the odb-tests > package. There is a type called string_ptr which is used to > test NULL-ness. The value_traits implementation is in the > traits.hxx file. > > Also, some of the types supported by profiles provide the notion > of NULL values and these type automatically store such values as > NULL in the database. Once such type QString in the Qt profile. > > Finally, in one of the upcoming versions we are planning to add > support for the boost::optional container which has a natural > mapping to a column with NULL enabled. This will make working > with NULL values a much more straightforward matter if you are > using Boost. Perhaps we will also provide our own version of > something like this in libodb, in case you cannot use Boost > for some reason. > > Boris > -- ALBEZA "Pause" Nicolas From boris at codesynthesis.com Fri Jul 22 11:21:49 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 22 11:24:25 2011 Subject: [odb-users] NULL Fields, how do they work ? In-Reply-To: References: Message-ID: Hi Nicolas, Nicolas ALBEZA writes: > Do you know when the version including this feature will be released ? It won't be 1.5.0 (out hopefully next week). So it will be the one after that which will probably be released in a month or month and a half. Boris From bhartsb at gmail.com Fri Jul 22 13:50:24 2011 From: bhartsb at gmail.com (B Hart) Date: Fri Jul 22 13:50:31 2011 Subject: [odb-users] Can one use ODB with Classes generated by XSD? Message-ID: Hello Boris, I have a large Schema that I compiled with XSD (tree). This allows me to nicely read in corresponding XML data. Now I'm faced with the task of populating an existing DB with the data. However, their are difficulties: 1) There are new elements that are not currently stored in the DB, so tables and columns will have to be manually added, 2) there is not a nice mapping between all of the Schema elements and the corresponding DB table/column...i.e.. some of the element data may have to be modified or combined to go into a DB field, and the document that specifies the mappings is incomplete (this means I have to look through hundreds of tables to "figure out" where data goes, for hundreds of elements). 3) Once I figure out the mapping I have to then add the code manually to populate the DB with the data. The DB is a MS SQL DB and right now ODB doesn't support MS SQL. However, it might be worth switching to MySQL if it were possible and reasonable to run ODB against the classes that XSD creates in order to create a correspond MySQL DB Schema and the code to populate it. Then I could read in the XML dataset with the XSD generated code and populate and work with the DB with ODB generated code. What are your thoughts. Best, Brian Hart From pena.rd at gmail.com Mon Jul 25 13:24:02 2011 From: pena.rd at gmail.com (Rafael Pena) Date: Mon Jul 25 13:24:12 2011 Subject: [odb-users] Null values for unset properties Message-ID: I have a class as below. Is there anyway that I can keep the two optional fields (double optionalValue, string optionalString) as null? If I don't set the optionValue it defaults to 0 and optionalString defaults to "". I know the queries can use is_null operator so I am guessing it can be changed somehow. NOT NULL is the default type in ddl generated by ODB, can I change the optional fields to #pragma db type("DOUBLE")? Is there a way to leave unset fields as null? #pragma db object class File { public: File() { } File(const string& filename); File(const File& orig); virtual ~File(); //Setters and Getters private: friend class odb::access; #pragma db id auto unsigned long fileId; //FileInformation string filename; string fileType; ptime fileDate; ptime converterStartdate; ptime converterEndDate; string loadingHost; unsigned long fileSize; #pragma db type("DOUBLE") // Can I do this? double optionalValue; string optionalString; }; From boris at codesynthesis.com Tue Jul 26 03:35:21 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 26 03:37:58 2011 Subject: [odb-users] ODB 1.5.0 released Message-ID: Hi, We have released ODB 1.5.0. The NEWS file entries for this release are as follows: * Support for the PostgreSQL database. The provided connection factories include 'new' (a new connection is created every time one is requested) and 'pool' (a pool of connections is maintained). The Boost and Qt profiles have been updated to support this database. For more information, refer to Chapter 13, "PostgreSQL Database" in the ODB manual. * New handling of the NULL semantics. Now, instead of being specified as part of the SQL type with the type pragma, there are separate null and not_null pragmas. The not_null pragma was used to control the NULL semantics of object pointers. Now the two pragmas are used consistently for object pointers and simple values (and, in the future, they will work for composite values and containers). To control the NULL semantics of the container's element values, the value_null and value_not_null pragmas have been added, similar to the value_type, value_column, etc., pragmas. For more information about the new mechanism, refer to Sections 10.2.3, 10.2.8, 10.3.4, and 10.3.13 in the ODB manual. This is a backwards-incompatible change. Existing use cases that will require manual changes are listed below. For pragmas that apply to simple value types and data members of such types: #pragma db type("TEXT NOT NULL") => #pragma db type("TEXT") #pragma db type("TEXT NULL") => #pragma db type("TEXT") null #pragma db type("TEXT") => #pragma db type("TEXT") null For pragmas that apply to containers of pointers and data members of such types: #pragma db not_null => #pragma db value_not_null * New pragma, default, allows the specification of the database default value. For more information, refer to Section 10.3.5, "default" in the ODB manual. * New pragmas, options, id_options, index_options, key_options, and value_options, allow the specification of additional column definition options. For more information, refer to Section 10.3.6, "options" in the ODB manual. * Support for database operations callbacks. Now a persistent class can register a callback function that will be called before and after every database operation (such as persist, load, update, or erase) is performed on an object of this class. A database operations callback can be used to implement object-specific pre and post initializations, registrations, and cleanups. For more information and an example, refer to Section 10.1.4, "callback" in the ODB manual. * New option, --include-regex, allows the modification of the #include directive paths generated by the ODB compiler. This is primarily useful when placing the generated code into subdirectories and the #include directives have to be adjusted accordingly. The --include-regex-trace option is useful for debugging the expressions specified with --include-regex. Source code and pre-compiled binary packages for this release are available from the ODB download page: http://www.codesynthesis.com/products/odb/download.xhtml SHA1 checksums for the files in this release are as follows: 3494e49d38aaaf26f7c087ab02e65e29fe59bd1d libodb-1.5.0.tar.bz2 edcd8a934542c960c06da04fb8fc6a9a8aa21544 libodb-1.5.0.tar.gz f87b424c2fabc651d5b5c30dda4bb46cf18b3210 libodb-1.5.0.zip 3b00efc7b8e43add78165ad6ef4a1b8ebb3a31f0 libodb-boost-1.5.0.tar.bz2 835b9448de0d4aeac7c0923a4e30efc9451f34e1 libodb-boost-1.5.0.tar.gz edfea119f5d279e4b51ad004caa63d623a667e84 libodb-boost-1.5.0.zip 2b5a7bef9493b47bf82a7568c8369f6cd8e94253 libodb-mysql-1.5.0.tar.bz2 836d784f53552a9641d0cbaf870a2e6563e4eb7b libodb-mysql-1.5.0.tar.gz 68e07e6c002f8c12826f5b3f15f2edfaa99ec9b0 libodb-mysql-1.5.0.zip 22f7cf7c8b689b68fc7ede5f76c8d31cffdc6e92 libodb-pgsql-1.5.0.tar.bz2 cfa7221dfa0ec28e2e45f285d8bf704ea7cb73e9 libodb-pgsql-1.5.0.tar.gz 64ac5c9dc841892c2fb76b2ae6d97d7b1d55a5fa libodb-pgsql-1.5.0.zip cfe802d549676fa2d1cf3d71ffbdf939df0a50b3 libodb-qt-1.5.0.tar.bz2 75fce37933d872f51a0ac565969750e9a6d5fa1f libodb-qt-1.5.0.tar.gz 616f570e6cd81ef62e5fe667f130da824e360aed libodb-qt-1.5.0.zip 524e5e8270e076d79980ccd00d23e4fd4ce309c4 libodb-sqlite-1.5.0.tar.bz2 13dd93d505250c8faa1fa00aa942ad01598e37d9 libodb-sqlite-1.5.0.tar.gz 4b5c43c12624e0dfe67cfd8fc52a1156b4d3840a libodb-sqlite-1.5.0.zip 6610dc40b91eeb9e0af750e953b96ad68f17c521 libodb-tracer-1.5.0.tar.bz2 bf2f6e7f94536148099ebd27ff5e26b5529f0ff7 libodb-tracer-1.5.0.tar.gz feb41d35e960654de148fdf79101622f61761719 libodb-tracer-1.5.0.zip 450c3865a647c820d7d342bd5d258901de484c74 odb-1.5.0-i686-linux-gnu.tar.bz2 6c183a8a92be4529fe578e399d0647e0187b00ab odb-1.5.0-i686-macosx.tar.bz2 d09757b3937b34cbfee050a94ca981c96a0c7646 odb-1.5.0-i686-solaris.tar.bz2 5a1f1e467cfcee95de653718781be1948c1a1bd7 odb-1.5.0-i686-windows.zip a5d8ad8c2464d5cbd703d78c81b96a1253310cc6 odb-1.5.0-sparc-solaris.tar.bz2 46c77261904407c4d6497f5c3dc6daaf15a3032a odb-1.5.0.tar.bz2 17eb28531b33adb144ac48da9fa655d0618ead37 odb-1.5.0.tar.gz a957777b57cc55d4a380358485b3e2ef91dc8c63 odb-1.5.0-x86_64-linux-gnu.tar.bz2 fc4744c369d08410b12c0914dd196b97c15ea726 odb-1.5.0.zip 34aa18ced8354778536f090cd393ffe60a428008 odb-examples-1.5.0.tar.bz2 5eb3aac99cb9d1021b39e70f42da371b81f5e968 odb-examples-1.5.0.tar.gz b58715a23ce22f3833fe74b5831226a01a87b4a0 odb-examples-1.5.0.zip bdc4bfde9224a2ab03fecf35b82887449b3d902c odb-tests-1.5.0.tar.bz2 35c9ac71d8f403a68018d63d7e3b33cfb7525ec4 odb-tests-1.5.0.tar.gz 9a99081f4ab17ce900d0ffaf6e64f42dddb1a93c odb-tests-1.5.0.zip Enjoy, Boris From boris at codesynthesis.com Tue Jul 26 09:15:29 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 26 09:18:04 2011 Subject: [odb-users] Null values for unset properties In-Reply-To: References: Message-ID: Hi Rafael, Rafael Pena writes: > NOT NULL is the default type in ddl generated by ODB, can I change > the optional fields to #pragma db type("DOUBLE")? Yes, you can do that. Or, you can upgrade to ODB 1.5.0 and use the new null pragma: #pragma db null double optionalValue; > Is there a way to leave unset fields as null? For answer to this question see this post from a few days ago: http://www.codesynthesis.com/pipermail/odb-users/2011-July/000193.html Boris From boris at codesynthesis.com Tue Jul 26 09:37:47 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 26 09:40:29 2011 Subject: [odb-users] Re: Can one use ODB with Classes generated by XSD? In-Reply-To: References: Message-ID: Hi Brian, B Hart writes: > I have a large Schema that I compiled with XSD (tree). This allows me to > nicely read in corresponding XML data. Now I'm faced with the task of > populating an existing DB with the data. However, their are difficulties: > 1) There are new elements that are not currently stored in the DB, so tables > and columns will have to be manually added, 2) there is not a nice mapping > between all of the Schema elements and the corresponding DB > table/column...i.e.. some of the element data may have to be modified or > combined to go into a DB field, and the document that specifies the mappings > is incomplete (this means I have to look through hundreds of tables to > "figure out" where data goes, for hundreds of elements). 3) Once I figure > out the mapping I have to then add the code manually to populate the DB with > the data. Yes, I think this is a fairly common problem when trying to import data from an XML vocabulary to a relational database, unless the XML vocabulary was specifically designed with that conversion in mind. > The DB is a MS SQL DB and right now ODB doesn't support MS SQL. However, it > might be worth switching to MySQL if it were possible and reasonable to run > ODB against the classes that XSD creates in order to create a correspond > MySQL DB Schema and the code to populate it. Then I could read in the XML > dataset with the XSD generated code and populate and work with the DB with > ODB generated code. The problem with automatically storing XSD-generated object model in a relational database using ODB is that the conversion is not well define and in fact is not always possible. It is not clear whether, say, a nested element should be mapped to a column (value type) or a reference to another table (object) with the contents of this element stored in that table. Some elements can be stored as either composite value types or as objects. Those that have more than two levels of sequence containment can only be stored as objects. > What are your thoughts. I see two possible approaches here, depending on how closely the XML vocabulary models the database representation. 1. If XML and database models are very different (as in the case you described above), then the best approach would probably be to have two object models (sets of C++ classes): the first is for XML (generated by the XSD compiler) and the second is for the database (hand-written or auto-generated by ODB SQL-to-C++ compiler from the existing schema, something that is on our TODO list). Once you have the two models, you manually write the code that convert between the two, such as performing merging and splitting of members, etc. 2. If XML models the database pretty closely, then you can take the XSD-generated model and map it (using ODB pragmas) to the database tables (those can be placed into a separate file and included into the ODB compilation with the --odb-epilogue option). Once that is done, you can just load the classes from XML and store them into the RDBMS. Boris From dcoffey at netharmonix.com Tue Jul 26 11:18:30 2011 From: dcoffey at netharmonix.com (Dan Coffey) Date: Tue Jul 26 11:18:37 2011 Subject: [odb-users] Error building - libodb-boost-1.5.0 with VC++ Message-ID: <4E2EDAC6.8060301@netharmonix.com> Hi Boris, I built the libodb-1.5.0 in VC++ 10 without any problems. I am getting an error on the libodb-boost-1.5.0 build. I expect I've missed something in the configuration. Thanks for you help. Dan VC++ properties - VC++ Directories: * ...\libodb-boost * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\include * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++ * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\i686-mingw32 * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\tr1 * D:\Development\C++\Boost\boost_1_47_0\boost Error Messages: 1> exceptions.cxx 1>d:\development\c++\odb-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\stddef.h(211): error C2371: 'size_t' : redefinition; different basic types 1> d:\development\c++\odb-1.5.0\libodb-boost-1.5.0\odb\boost\predefined c++ types (compiler internal)(19) : see declaration of 'size_t' 1>d:\development\c++\odb-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\bits\functexcept.h(43): error C3646: '__attribute__' : unknown override specifier From bhartsb at gmail.com Tue Jul 26 11:57:56 2011 From: bhartsb at gmail.com (B Hart) Date: Tue Jul 26 11:58:05 2011 Subject: [odb-users] Re: Can one use ODB with Classes generated by XSD? In-Reply-To: References: Message-ID: Thanks for your explanation. Where you say "(those can be placed into a separate file and included into the ODB compilation with the --odb-epilogue option)." do you mean the xsd-generated classes with pragmas? So hypothetically, if I decided to create a whole new DB (based on the XML Schema and using ODB), how would I best use the XSD-generated classes with ODB to do this? Will ODB create a complete DB from the XSD-generated output? I understand that ODB doesnt' support MS SQL currently so I am assuming the use MySQL in this case. -Brian On Tue, Jul 26, 2011 at 6:37 AM, Boris Kolpackov wrote: > Hi Brian, > > B Hart writes: > > > I have a large Schema that I compiled with XSD (tree). This allows me to > > nicely read in corresponding XML data. Now I'm faced with the task of > > populating an existing DB with the data. However, their are > difficulties: > > 1) There are new elements that are not currently stored in the DB, so > tables > > and columns will have to be manually added, 2) there is not a nice > mapping > > between all of the Schema elements and the corresponding DB > > table/column...i.e.. some of the element data may have to be modified or > > combined to go into a DB field, and the document that specifies the > mappings > > is incomplete (this means I have to look through hundreds of tables to > > "figure out" where data goes, for hundreds of elements). 3) Once I > figure > > out the mapping I have to then add the code manually to populate the DB > with > > the data. > > Yes, I think this is a fairly common problem when trying to import data > from an XML vocabulary to a relational database, unless the XML vocabulary > was specifically designed with that conversion in mind. > > > > The DB is a MS SQL DB and right now ODB doesn't support MS SQL. However, > it > > might be worth switching to MySQL if it were possible and reasonable to > run > > ODB against the classes that XSD creates in order to create a correspond > > MySQL DB Schema and the code to populate it. Then I could read in the > XML > > dataset with the XSD generated code and populate and work with the DB > with > > ODB generated code. > > The problem with automatically storing XSD-generated object model in > a relational database using ODB is that the conversion is not well > define and in fact is not always possible. It is not clear whether, > say, a nested element should be mapped to a column (value type) or > a reference to another table (object) with the contents of this > element stored in that table. Some elements can be stored as either > composite value types or as objects. Those that have more than two > levels of sequence containment can only be stored as objects. > > > > What are your thoughts. > > I see two possible approaches here, depending on how closely the > XML vocabulary models the database representation. > > 1. If XML and database models are very different (as in the case you > described above), then the best approach would probably be to have two > object models (sets of C++ classes): the first is for XML (generated > by the XSD compiler) and the second is for the database (hand-written > or auto-generated by ODB SQL-to-C++ compiler from the existing schema, > something that is on our TODO list). Once you have the two models, you > manually write the code that convert between the two, such as > performing merging and splitting of members, etc. > > 2. If XML models the database pretty closely, then you can take the > XSD-generated model and map it (using ODB pragmas) to the database > tables (those can be placed into a separate file and included into > the ODB compilation with the --odb-epilogue option). Once that is > done, you can just load the classes from XML and store them into > the RDBMS. > > Boris > From boris at codesynthesis.com Tue Jul 26 14:27:12 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 26 14:29:49 2011 Subject: [odb-users] Error building - libodb-boost-1.5.0 with VC++ In-Reply-To: <4E2EDAC6.8060301@netharmonix.com> References: <4E2EDAC6.8060301@netharmonix.com> Message-ID: Hi Dan, Dan Coffey writes: > VC++ properties - VC++ Directories: > > * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\include > * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include > * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++ > * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\i686-mingw32 > * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\tr1 I don't understand we you insist on adding these directories to the compiler's search paths (you have done similar things before when trying to build for MinGW). You are definitely not instructed to do so by any documentation that comes with ODB. The odb-1.5.0-i686-windows\mingw directory is the ODB compiler's implementation detail. You never need to reference any of the paths in this directory. Try to imagine it does not exist ;-). Boris From dcoffey at netharmonix.com Wed Jul 27 08:32:13 2011 From: dcoffey at netharmonix.com (Dan Coffey) Date: Wed Jul 27 08:32:21 2011 Subject: [odb-users] Error building - libodb-boost-1.5.0 with VC++ In-Reply-To: References: <4E2EDAC6.8060301@netharmonix.com> Message-ID: <4E30054D.3030708@netharmonix.com> Hi Boris, Thanks for you patience. I go back and try you suggestion later. For now I've gone back to building using mingw and MinGW Shell. Once I got the -I and -L paths correct, I was able to make and install libodb, libodb-boost libodb-qt and libodb-mysql lib's without any problems. Dan On 7/26/2011 2:27 PM, Boris Kolpackov wrote: > Hi Dan, > > Dan Coffey writes: > >> VC++ properties - VC++ Directories: >> >> * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\include >> * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include >> * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++ >> * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\i686-mingw32 >> * D:\Development\C++\ODB-1.5.0\odb-1.5.0-i686-windows\mingw\lib\gcc\i686-mingw32\4.5.1\include\c++\tr1 > I don't understand we you insist on adding these directories to the > compiler's search paths (you have done similar things before when > trying to build for MinGW). You are definitely not instructed to > do so by any documentation that comes with ODB. > > The odb-1.5.0-i686-windows\mingw directory is the ODB compiler's > implementation detail. You never need to reference any of the paths > in this directory. Try to imagine it does not exist ;-). > > Boris From losintikfos at yahoo.co.uk Wed Jul 27 04:52:49 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Wed Jul 27 09:32:28 2011 Subject: [odb-users] Storing and retrieving Images using ODB and MySQL Message-ID: <1311756769.76844.YahooMailClassic@web29304.mail.ird.yahoo.com> Is there any example on storing and retrieving images to MySQL using ODB? Thanks From boris at codesynthesis.com Wed Jul 27 10:17:23 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 27 10:19:59 2011 Subject: [odb-users] Re: Can one use ODB with Classes generated by XSD? In-Reply-To: References: Message-ID: Hi Brian, B Hart writes: > Where you say "(those can be placed into a separate file and included into > the ODB compilation with the --odb-epilogue option)." do you mean the > xsd-generated classes with pragmas? XSD-generated classes do not have any pragmas (XSD doesn't know anything about ODB). So you will need to add those pragmas yourself, which can be placed into a separate file (we call it a "mapping" file) and "added" to the ODB compilation process (when you compile the XSD-generated header) using the --odb-epilogue option. > So hypothetically, if I decided to create a whole new DB (based on the XML > Schema and using ODB), how would I best use the XSD-generated classes with > ODB to do this? Will ODB create a complete DB from the XSD-generated > output? No, as I explained above, you will need to "tell" ODB how to map the XSD-generated classes to the database, just as you would do for hand- written code. ODB has no idea which XSD-generated classes should be objects, which should be value types, which attribute/element is the object id, etc. Only you can decide such aspects of the mapping. There will be other difficulties as well. Here are a few from the top of my head: 1. All data members in the XSD-generated classes are protected which makes them inaccessible to ODB. To overcome this, you could post- process the XSD-generated header with a script and replace 'protected:' with 'public:'. Alternatively, we can add an option to XSD to generate data members public. 2. XSD uses wrapper templates for 'one' and 'optional' members. ODB will not know how to "unwrap" them without some help from your side (value_traits). We are currently working on the 'wrapper' concept for ODB which will make handling this much easier. 3. You will need an id member for every object class. This may or may not be a problem in your case. Support for objects without an explicit object id is also on our TODO list. Boris From boris at codesynthesis.com Wed Jul 27 10:37:51 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 27 10:40:28 2011 Subject: [odb-users] Null values for unset properties In-Reply-To: References: Message-ID: Hi Rafael, Rafael Pena writes: > I figured it out. My image_type was wrong. This is working. > > typedef double_ptr value_type; > typedef double query_type; > typedef double_ptr image_type; That doesn't look right. image_type should be double, not double_ptr. I created a test for this and it works fine using your original version. Here is the traits specialization for MySQL, saved into traits.hxx: #ifndef TRAITS_HXX #define TRAITS_HXX #include #include namespace odb { namespace mysql { typedef boost::shared_ptr double_ptr; template <> class value_traits { public: typedef double_ptr value_type; typedef double query_type; typedef double image_type; static void set_value(double_ptr& v, const double& b, bool is_null) { v.reset (is_null ? 0 : new double (b)); } static void set_image(double& b, bool& is_null, const double_ptr& v) { is_null = (v.get() == 0); if (!is_null) b = *v; } }; } } #endif // TRAITS_HXX Then I included it into the generated header file with this option: --hxx-prologue '#include "traits.hxx"' The header file that uses double_ptr looks like this (using the new null pragma from 1.5.0): typedef boost::shared_ptr double_ptr; #pragma db value(double_ptr) type("DOUBLE") null #pragma db object struct object { #pragma db id auto unsigned long id_; double_ptr d_; }; Boris From boris at codesynthesis.com Thu Jul 28 04:27:30 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 28 04:30:08 2011 Subject: [odb-users] Storing and retrieving Images using ODB and MySQL In-Reply-To: <1311756769.76844.YahooMailClassic@web29304.mail.ird.yahoo.com> References: <1311756769.76844.YahooMailClassic@web29304.mail.ird.yahoo.com> Message-ID: Hi, Bright Dadson writes: > Is there any example on storing and retrieving images to MySQL using ODB? Without saying anything about whether it is a good idea in the first place, the way to do this is probably to store an image as a BLOB. To work with BLOBs in the current release (1.5.0) you would need to provide your own C++ buffer type and also implement the value_traits specialization for it (see the 'mapping' example for more information on how to do this). For some time now I meant to add support for mapping std::vector to BLOB types and I finally got around to adding this. So if you would like to use that functionality, you will need to do these things (once 1.6.0 is released these steps will be unnecessary): 1. Get the traits.hxx and traits.cxx files from this commit: http://scm.codesynthesis.com/?p=odb/libodb-mysql.git;a=commit;h=e8162bdac61ac49ae30cdfeae9f2bd3d230df809 And copy them to your libodb-mysql source directory (in odb/mysql/) 2. Re-build and re-install libodb-mysql. After that, you can do something like this: #pragma db object class object { #pragma db type("BLOB") std::vector image_; }; To copy the data into the image, you can do: object o; const char* image_bytes = ... std::size_t image_size = ... o.image_.assign (image_bytes, image_bytes + image_size); To read the data from the image, you can do: object o = ... const char* image_bytes = o.image_.data (); std::size_t image_size = o.image_.size (); Boris From losintikfos at yahoo.co.uk Thu Jul 28 15:23:27 2011 From: losintikfos at yahoo.co.uk (Bright Dadson) Date: Fri Jul 29 08:17:54 2011 Subject: [odb-users] Storing and retrieving Images using ODB and MySQL In-Reply-To: Message-ID: <1311881007.8378.YahooMailClassic@web29305.mail.ird.yahoo.com> OMG! Boris - this is more than helpful. Thanks very much. --- On Thu, 28/7/11, Boris Kolpackov wrote: From: Boris Kolpackov Subject: Re: [odb-users] Storing and retrieving Images using ODB and MySQL Hi, Bright Dadson writes: > Is there any example on storing and retrieving images to MySQL using ODB? Without saying anything about whether it is a good idea in the first place, the way to do this is probably to store an image as a BLOB. To work with BLOBs in the current release (1.5.0) you would need to provide your own C++ buffer type and also implement the value_traits specialization for it (see the 'mapping' example for more information on how to do this). For some time now I meant to add support for mapping std::vector to BLOB types and I finally got around to adding this. So if you would like to use that functionality, you will need to do these things (once 1.6.0 is released these steps will be unnecessary): 1. Get the traits.hxx and traits.cxx files from this commit: ???http://scm.codesynthesis.com/?p=odb/libodb-mysql.git;a=commit;h=e8162bdac61ac49ae30cdfeae9f2bd3d230df809 ???And copy them to your libodb-mysql source directory (in odb/mysql/) 2. Re-build and re-install libodb-mysql. After that, you can do something like this: #pragma db object class object { ? #pragma db type("BLOB") ? std::vector image_; }; To copy the data into the image, you can do: object o; const char* image_bytes = ... std::size_t image_size = ... o.image_.assign (image_bytes, image_bytes + image_size); To read the data from the image, you can do: object o = ... const char* image_bytes = o.image_.data (); std::size_t image_size = o.image_.size (); Boris