Hi, all,
I am still using 0.9.8, and not sure if this is still an issue in later
version of OJB. But I hope anyone with information can drop me a hint
I have a class, says A, which has FK reference to a number of other classes,
says B, C. Now let's say A has two fields,
A.Field1
A.Field2
Both fields are primary keys to A and are forigen keys to B and C
respectively. So in the repository.xml it is something like
<class A>
<field id=1 name=FieldA/>
<field id=2 name=FieldB/>
<field id=3 name=someOtherField/>
<reference-descriptor aFieldB>
class-ref="B"
<foreignkey field-id-ref="1">
<foreignkey field-id-ref="2">
</reference-descriptor>
<reference-descriptor aFieldC>
class-ref="C"
<foreignkey field-id-ref="1">
<foreignkey field-id-ref="2">
</reference-descriptor>
</class>
I have turned the auto-retrieval of C off, then I hit this problem:
when I try to update A (says changing the value in "someOtherField") , I
dicovered that the key fields (FieldA and FieldB) are always set to null. It
is because in function assertFkAssignment() in PersistenceBrokerImpl, when a
referenced object (class C in this case) is null, the FK fields are set to
null, which happens to be primary fields as well. So the subsequent update
failed since the keys are not invalid.
I guess the assetFkAssignment should not set the fields in class A to null
in this case, because the missing of the referenced object, C, is
purposeful. I wonder if
1) someone has encountered this before?
2) is it a issue? or it is because i have used the auto-retrieval
improperly?
3) If it is a issue, what should be a solution? I guess the function should
not modify PK fields, and better still detect if auto-retrieval is in effect
or not.
4) Is it still the case in 0.9.9 and beyond. AFAIK, in 0.9.9, the function
assertFkAssignment is not changed at all?
I have simplified the case to illustrate the point. If you still like to see
the actual xml please kindly let me know.
Regards,
Anthony