// then return the attached copy
if (o != null)
return o;
Object oid = ((PersistentObjectItf)detached).speedoGetEncodedPName();
PersistentObjectItf sp = null;
try {
if (oid == null) {
//make the object persistent
speedoMakePersistent((PersistentObjectItf) detached, map);
//return detached;
sp = (PersistentObjectItf) detached;
} else {
sp = (PersistentObjectItf) speedoGetObjectById(oid, false);
}
sp.speedoGetHome().sendEvent(HomeItf.PRE_ATTACH, sp, null);
StateItf sar = sp.speedoGetHome().readIntention(sp, null);
//if made persistent in this method
// force the state to detached_dirty
if (oid == null) {
sar.forceDetachedDirty();
}
//call the attach method on the po
sp.speedoGetHome().attachCopy(sp, this, map, detached, sar);
// if made persistent in this method
// restore the state to detached_none
if (oid == null) {
sar.restoreDetachedNone();
}
//change the version on attach
sar.speedoChangeVersion();
sp.speedoGetHome().sendEvent(HomeItf.POST_ATTACH, sp, null);
return sp;
} catch (Exception e) {
Exception ie = ExceptionHelper.getNested(e);
String msg = "Impossible to attach a copy of the persistent object with the identifier: " + oid;
logger.log(BasicLevel.INFO, msg, ie);