Hello,
I was wondering how can i solve the creation of 2 objects with an 1-
to-1 relationship. Using this example class:
<class>
<name>user</name>
<variable>
<name>profile_id</name>
<class>profile</class>
</variable>
</class>
and...
<class>
<name>profile</name>
<variable>
<name>user_id</name>
<class>user</class>
</variable>
</class>
I've created 2 object factory functions of type createobject, one for
each class of user and profile. But it returns that a missing
argument is missing, which is the profile_id and user_id.
As it sustends 'applications should not access reference variables
directly to manipulate the respective objects. Instead you should
declare and use functions of type setreference and getreference to
assign or retrieve the related objects by storing or de-referencing
the respective OID. '
And:
'Applications should not access reference variables directly to
manipulate the respective objects. Instead you should declare and use
functions of type setreference and getreference to assign or retrieve
the related objects by storing or de-referencing the respective OID.
See the section ahead about defining data objects functions to learn
how to declare and use this type of functions.'
How can i create object user and profile and set references in a form
of 1-to-1 relationship? Like this?
<function>
<name>setprofileid</name>
<type>setreference</type>
<parameters>
<variable>profile_id</variable>
<reference>
<argument>profile</argument>
</reference>
</parameters>
</function>
<function>
<name>setuserid</name>
<type>setreference</type>
<parameters>
<variable>user_id</variable>
<reference>
<argument>user</argument>
</reference>
</parameters>
</function>
Also, should i call these functions before persist the database?
Thanks in advance,
regards,
miguel