Hi Cory,
if you store an object without populated reference (e.g. when using
auto-retrieve false), OJB assume that the reference is removed and
nullify the FK.
http://db.apache.org/ojb/docu/guides/basic-technique.html#auto-retrieve+setting
regards,
Armin
Cory Prowse wrote:
Ah, I goofed in sending through the example class descriptor, the value for
auto-retrieve should in fact be false (as mentioned in the email subject
heading).
It really has been one of those weeks ;)
As a result my example steps are wrong as well, sorry about that.
So the problem is that after loading the Parent, the child _object_ is NOT
loaded, which is to be expected (and desired) since the auto-retrieve is
false on that reference-descriptor.
However the foreign key field IS loaded properly, which is good and desired
as well.
However after storing the object the foreign key column is not set in the
database.
It seems OJB might be using the object reference to get the foreign key
value even though auto-retrieve is set to false and it won't be there.
This is in OJB 1.0.1
-- Cory
An example of the full class descriptor is:
<class-descriptor
class="com.example.Parent"
table="parent">
<field-descriptor
name="id"
column="parent_id"
jdbc-type="INTEGER"
primarykey="true"
nullable="false"
autoincrement="true"/>
<field-descriptor
name="childId"
column="child_id"
jdbc-type="INTEGER"
primarykey="false"
nullable="true"/>
<reference-descriptor
name="child"
class-ref="com.example.Child"
auto-update="true"
auto-retrieve="false"
auto-delete="false">
<foreignkey field-ref="childId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor
class="com.example.Child"
table="child">
<field-descriptor
name="id"
column="child_id"
jdbc-type="INTEGER"
primarykey="true"
nullable="false"
autoincrement="true"/>
<field-descriptor
name="name"
column="name"
jdbc-type="VARCHAR"
primarykey="false"
nullable="true"/>
</class-descriptor>
-----Original Message-----
From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
Sent: Friday, 8 July 2005 2:52 AM
To: OJB Users List
Subject: Re: Foriegn Key field not populated when
auto-retrieve="false"
Could you perhaps provide some more info, specifically the complete
class descriptor (or a comparative sample) and your usage of OJB for
storing and retrieving the object ?
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]