[odb-users] Pointer as a member of Class

Boris Kolpackov boris at codesynthesis.com
Tue Sep 16 11:48:51 EDT 2014


Hi Nima,

nima chavooshi <nima0102 at gmail.com> writes:

> I think I could not explain what I expect. Please kindly see my classes:

You are still not telling me what you do and when you expect! I
see your classes and there is nothing particularly wrong with
them (there is a lot of room for improvement from the "good
C++" point of view, but that's another story).

So based on your previous email I am guessing what you are trying
to do is something like this:

Person p;
p.ContactPerson = new Contact;

db.persist (p);

And expect this call to persist() to store both Person and
Contact in the database. If so, then re-read my previous
reply, which sums up to: "this is not how ODB works".
Instead, you need to do:

db.persist (p.ContactPerson);
db.persist (p);

 
> And also I doubt about generated schema, because there is no any
> "REFERENCE" keyword in schema then there is no defined relationship
> between 2 tables.

There should be a foreign key defined in the table for Person. Make
sure also that you #include your Contact header into Person header.
If that doesn't work, tell me exactly what is wrong. And I mean
exactly: exact command lines that you use to invoke ODB, the
schema that you get, etc.

Boris



More information about the odb-users mailing list