public Object fetchInitialField(int field) {
FieldMetaData fmd = _meta.getField(field);
if (_broker.getRestoreState() == RestoreState.RESTORE_NONE
&& ((_flags & FLAG_INVERSES) == 0
|| fmd.getInverseMetaDatas().length == 0))
throw new InvalidStateException(_loc.get("restore-unset"));
switch (fmd.getDeclaredTypeCode()) {
case JavaTypes.DATE:
case JavaTypes.CALENDAR:
case JavaTypes.ARRAY:
case JavaTypes.COLLECTION:
case JavaTypes.MAP:
case JavaTypes.OBJECT:
// if we're not saving mutable types, throw an exception
if (_broker.getRestoreState() != RestoreState.RESTORE_ALL
&& ((_flags & FLAG_INVERSES) == 0
|| fmd.getInverseMetaDatas().length == 0))
throw new InvalidStateException(_loc.get
("mutable-restore-unset"));
}
lock();
try {
if (_saved == null || !_loaded.get(field) || !isFieldDirty(field))
return fetchField(field, false);
// if the field is dirty but we never loaded it, we can't restore it
if (_saved.getUnloaded().get(field))
throw new InvalidStateException(_loc.get("initial-unloaded",
fmd));
provideField(_saved.getState(), _single, field);
return fetchField(_single, fmd);
} finally {