if (call == null)
call = this;
oid = call.processArgument(oid);
if (oid == null) {
if ((flags & OID_NOVALIDATE) == 0)
throw new ObjectNotFoundException(_loc.get("null-oid"));
return call.processReturn(oid, null);
}
if (fetch == null)
fetch = _fc;
beginOperation(true);
try {
assertNontransactionalRead();
// cached instance?
StateManagerImpl sm = getStateManagerImplById(oid,
(flags & OID_ALLOW_NEW) != 0 || (_flags & FLAG_FLUSHED) != 0);
if (sm != null) {
if (!requiresLoad(sm, true, fetch, edata, flags))
return call.processReturn(oid, sm);
if (!sm.isLoading()) {
// make sure all the configured fields are loaded; do this
// after making instance transactional for locking
if (!sm.isTransactional() && useTransactionalState(fetch))
sm.transactional();
boolean loaded;
try {
loaded = sm.load(fetch, StateManagerImpl.LOAD_FGS,
exclude, edata, false);
} catch (ObjectNotFoundException onfe) {
if ((flags & OID_NODELETED) != 0
|| (flags & OID_NOVALIDATE) != 0)
throw onfe;
return call.processReturn(oid, null);
}
// if no data needed to be loaded and the user wants to
// validate, just make sure the object exists
if (!loaded && (flags & OID_NOVALIDATE) == 0
&& _compat.getValidateTrueChecksStore()
&& !sm.isTransactional()
&& !_store.exists(sm, edata)) {
if ((flags & OID_NODELETED) == 0)
return call.processReturn(oid, null);
throw new ObjectNotFoundException(_loc.get
("del-instance", sm.getManagedInstance(), oid)).
setFailedObject(sm.getManagedInstance());
}
}
// since the object was cached, we may need to upgrade lock
// if current level is higher than level of initial load
if ((_flags & FLAG_ACTIVE) != 0) {
int level = fetch.getReadLockLevel();
_lm.lock(sm, level, fetch.getLockTimeout(), edata);
sm.readLocked(level, fetch.getWriteLockLevel());
}
return call.processReturn(oid, sm);
}
// if there's no cached sm for a new/transient id type, we
// it definitely doesn't exist
if (oid instanceof StateManagerId)
return call.processReturn(oid, null);
// initialize a new state manager for the datastore instance
sm = newStateManagerImpl(oid, (flags & OID_COPY) != 0);
boolean load = requiresLoad(sm, false, fetch, edata, flags);
sm = initialize(sm, load, fetch, edata);
if (sm == null) {
if ((flags & OID_NOVALIDATE) != 0)
throw new ObjectNotFoundException(oid);
return call.processReturn(oid, null);
}
// make sure all configured fields were loaded
if (load) {