[odb-users] Create New Object

Scott Zhang macromarship at gmail.com
Mon Jun 24 06:27:50 EDT 2013


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:

> Hello,
>
> 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.
> Tarik
>


More information about the odb-users mailing list