if (LOG.isDebugEnabled()) {
LOG.debug("recreating adapter: oid=" + oid);
}
final Object pojo = objectStoreInstances.getPojo(oid);
final ObjectAdapter existingAdapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
if (existingAdapterLookedUpByPojo != null) {
// this could happen if we rehydrate a persisted object that
// depends on another persisted object
// not yet rehydrated.
getPersistenceSession().removeAdapter(existingAdapterLookedUpByPojo);
}
final ObjectAdapter existingAdapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
if (existingAdapterLookedUpByOid != null) {
throw new IsisException("A mapping already exists for " + oid + ": " + existingAdapterLookedUpByOid);
}
final ObjectAdapter recreatedAdapter = getPersistenceSession().mapRecreatedPojo(oid, pojo);
final Version version = objectStoreInstances.getVersion(oid);
recreatedAdapter.setVersion(version);
}
}