if (pc == null)
{
if (relationType == RelationType.MANY_TO_ONE_UNI)
{
// Update join table entry
PersistableRelationStore store =
(PersistableRelationStore) storeMgr.getBackingStoreForField(
sm.getExecutionContext().getClassLoaderResolver(), mmd, mmd.getType());
store.remove(sm);
}
return;
}
else
{
ObjectProvider otherSM = sm.getExecutionContext().findObjectProvider(pc);
if (otherSM == null)
{
if (relationType == RelationType.ONE_TO_ONE_BI || relationType == RelationType.MANY_TO_ONE_BI ||
relationType == RelationType.MANY_TO_ONE_UNI)
{
// Related object is not yet persisted (e.g 1-1 with FK at other side) so persist it
Object other = sm.getExecutionContext().persistObjectInternal(pc, null, -1, ObjectProvider.PC);
otherSM = sm.getExecutionContext().findObjectProvider(other);
}
}
if (relationType == RelationType.MANY_TO_ONE_UNI)
{
// Update join table entry
PersistableRelationStore store =
(PersistableRelationStore) storeMgr.getBackingStoreForField(
sm.getExecutionContext().getClassLoaderResolver(), mmd, mmd.getType());
store.update(sm, otherSM);
}
}
}