[odb-users] Create New Object

Tarik BENZ tenchu.tarik at hotmail.fr
Mon Jun 24 06:39:55 EDT 2013

Hello Scott,

Thank you for the answer,
Actually what I want is :
I have an "ID" for an entry to MyOtherClass table
I want to create a new  "MyClass" and affect the "ID" the the foo object.

Kind Regards,

Date: Mon, 24 Jun 2013 18:27:50 +0800
Subject: Re: [odb-users] Create New Object
From: macromarship at gmail.com
To: tenchu.tarik at hotmail.fr
CC: odb-users at codesynthesis.com

Hi. Tarik.
   If you create MyClass directly. the foo within it will be null, or uninitialized.

On Mon, Jun 24, 2013 at 4:26 PM, Tarik BENZ <tenchu.tarik at hotmail.fr> wrote:


I have an a class like this :

class MyClass


     std::shared_ptr<MyOtherClass> foo;


My question is :

"MyOtherClass" refers to a database table.

To create a new "MyClass" object, do I need to retrieve the data

into "MyOtherClass" from the database then affect this object to "foo"

or I can just use the "ID" of the "MyOtherClass"?

Because for the moment I load all the "MyOtherClass" data from the database,

then I try to find the correct entry with it's "ID". I am not sure It is the correct way

because it is really too heavy to do this!

Thank you in advance for your help.



More information about the odb-users mailing list