public void link ( Object targetObject , ClassDescriptor cld , ObjectReferenceDescriptor rds , Object referencedObject , boolean insert ) { // MBAIRD: we have 'disassociated' this object from the referenced object, // the object represented by the reference descriptor is now null, so set // the fk in the target object to null. // arminw: if an insert was done and ref object was null, we should allow // to pass FK fields of main object (maybe only the FK fields are set) if ( referencedObject == null ) { /* arminw: if update we set FK fields to 'null', because reference was disassociated We do nothing on insert, maybe only the FK fields of main object (without materialization of the reference object) are set by the user */ if ( ! insert ) { unlinkFK ( targetObject , cld , rds ) ; } } else { setFKField ( targetObject , cld , rds , referencedObject ) ; } }
Assign FK value to target object by reading PK values of referenced object .