Hi,

Christopher Cheng wrote:
It seems that if set "auto-retrieve" to false for foreign key object, when I call broker.store(), it will also set the foreign key to null also!

Supposing I have 2 tables Checks and CheckBooks

<class-descriptor
        class="Check"
        table="Checks">
     <field-descriptor
            name="checkBookId"
            column="CheckBookId"
            jdbc-type="BIGINT"
            />
     ....
     <reference-descriptor
            name="checkBook"
            class-ref="CheckBook"
            auto-retrieve="false"
            auto-update="false"
            auto-delete="false">
        <foreignkey field-ref="checkBookId"/>
    </reference-descriptor>
</class-descriptor>

As I call
broker.retrieveObject,
the checkbook attribute is null because auto-retrieve = false

As I call
broker.store(check);
OJB will set checkBookId to null also!!

Is the only way to do is to use proxy??

this would solve the problem.
Or use PB.retrieveAllReferences to load all references before upate the
object.

Is there any other easy way to do prevent this from happening?


With the default PB-api no, because OJB can't decide whether the
reference is null because of auto-retrieve="false" or someone set the
reference to null after materialize it.

You can cast the PB instance to PersistenceBrokerInternal and use method
#store(Object obj, Identity oid, ClassDescriptor cld, boolean insert,
boolean ignoreReferences)
with argument 'ignoreReferences' set to 'true'. In this case OJB will
completely ignore all references and only update the fields of the object.

regards,
Armin




---------------------------------------------------------------------
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]

Reply via email to