{
runningDetachAllOnCommit = true;
// Detach all detachment root objects (causes recursion through the fetch plan)
StateManager[] smsToDetach = detachAllOnCommitSMs;
DetachState state = new DetachState(getApiAdapter());
for (int i=0;i<smsToDetach.length;i++)
{
Object pc = smsToDetach[i].getObject();
if (pc != null)
{