}
ObjectManager om = ObjectManagerHelper.getObjectManager(obj);
if (om != null && om != this)
{
// Object managed by a different manager
throw new JPOXUserException(LOCALISER.msg("010007", obj));
}
Object persistedPc = obj; // Persisted object is the passed in pc (unless being attached as a copy)
if (getApiAdapter().isDetached(obj))
{
// Detached : attach it
assertDetachable(obj);
if (copyOnAttach)
{
// Attach a copy and return the copy
persistedPc = attachObjectCopy(obj, getApiAdapter().getIdForObject(obj) == null);
}
else
{
// Attach the object
attachObject(obj, getApiAdapter().getIdForObject(obj) == null);
persistedPc = obj;
}
}
else if (getApiAdapter().isTransactional(obj) && !getApiAdapter().isPersistent(obj))
{
// TransientTransactional : persist it
StateManager sm = findStateManager(obj);
if (sm == null)
{
throw new JPOXUserException(LOCALISER.msg("010007", getApiAdapter().getIdForObject(obj)));
}
sm.makePersistentTransactionalTransient();
}
else if (!getApiAdapter().isPersistent(obj))
{