* </ul>
* @param ownerOP ObjectProvider of the owner
*/
public void postUpdate(ObjectProvider ownerOP)
{
ExecutionContext ec = ownerOP.getExecutionContext();
Collection value = (Collection) ownerOP.provideField(mmd.getAbsoluteFieldNumber());
if (containerIsStoredInSingleColumn())
{
// Make sure the elements are ok for proceeding
SCOUtils.validateObjectsForWriting(ownerOP, value);
return;
}
if (value == null)
{
// remove any elements in the collection and replace it with an empty SCO wrapper
((CollectionStore) storeMgr.getBackingStoreForField(ec.getClassLoaderResolver(), mmd, null)).clear(ownerOP);
replaceFieldWithWrapper(ownerOP, null, false, false);
return;
}
if (value instanceof SCOContainer)
{
// Already have a SCO value
SCOContainer sco = (SCOContainer) value;
if (ownerOP.getObject() == sco.getOwner() && mmd.getName().equals(sco.getFieldName()))
{
// Flush any outstanding updates
sco.flush();
return;
}
if (sco.getOwner() != null)
{
throw new NucleusException(LOCALISER.msg("CollectionMapping.WrongOwnerError")).setFatal();
}
}
if (!mmd.isCascadeUpdate())
{
// TODO Should this throw exception if the element doesn't exist?
// User doesn't want to update by reachability
if (NucleusLogger.PERSISTENCE.isDebugEnabled())
{
NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("007008", mmd.getFullFieldName()));
}
return;
}
if (NucleusLogger.PERSISTENCE.isDebugEnabled())
{
NucleusLogger.PERSISTENCE.debug(LOCALISER.msg("007009", mmd.getFullFieldName()));
}
CollectionStore backingStore = ((CollectionStore) storeMgr.getBackingStoreForField(
ec.getClassLoaderResolver(), mmd, value.getClass()));
backingStore.update(ownerOP, value);
// Replace the field with a wrapper containing these elements
replaceFieldWithWrapper(ownerOP, value, false, false);
}