StateManagerImpl sm, FieldMetaData fmd, boolean nullLoaded) {
if (fmd.isVersion()
|| fmd.getManagement() != FieldMetaData.MANAGE_PERSISTENT)
return false;
PersistenceCapable into = sm.getPersistenceCapable();
int i = fmd.getIndex();
provideField(toAttach, sm, i);
int set = StateManager.SET_ATTACH;
Object val;
switch (fmd.getDeclaredTypeCode()) {
case JavaTypes.BOOLEAN:
sm.settingBooleanField(into, i, sm.fetchBooleanField(i),
fetchBooleanField(i), set);
break;
case JavaTypes.BYTE:
sm.settingByteField(into, i, sm.fetchByteField(i),
fetchByteField(i), set);
break;
case JavaTypes.CHAR:
sm.settingCharField(into, i, sm.fetchCharField(i),
fetchCharField(i), set);
break;
case JavaTypes.DOUBLE:
sm.settingDoubleField(into, i, sm.fetchDoubleField(i),
fetchDoubleField(i), set);
break;
case JavaTypes.FLOAT:
sm.settingFloatField(into, i, sm.fetchFloatField(i),
fetchFloatField(i), set);
break;
case JavaTypes.INT:
sm.settingIntField(into, i, sm.fetchIntField(i),
fetchIntField(i), set);
break;
case JavaTypes.LONG:
sm.settingLongField(into, i, sm.fetchLongField(i),
fetchLongField(i), set);
break;
case JavaTypes.SHORT:
sm.settingShortField(into, i, sm.fetchShortField(i),
fetchShortField(i), set);
break;
case JavaTypes.STRING:
String sval = fetchStringField(i);
if (sval == null && !nullLoaded)
return false;
sm.settingStringField(into, i, sm.fetchStringField(i), sval,
set);
break;
case JavaTypes.DATE:
case JavaTypes.CALENDAR:
case JavaTypes.NUMBER:
case JavaTypes.BOOLEAN_OBJ:
case JavaTypes.BYTE_OBJ:
case JavaTypes.CHAR_OBJ:
case JavaTypes.DOUBLE_OBJ:
case JavaTypes.FLOAT_OBJ:
case JavaTypes.INT_OBJ:
case JavaTypes.LONG_OBJ:
case JavaTypes.SHORT_OBJ:
case JavaTypes.BIGDECIMAL:
case JavaTypes.BIGINTEGER:
case JavaTypes.LOCALE:
case JavaTypes.OBJECT:
case JavaTypes.OID:
case JavaTypes.ENUM:
val = fetchObjectField(i);
if (val == null && !nullLoaded)
return false;
sm.settingObjectField(into, i, sm.fetchObjectField(i), val,
set);
break;
case JavaTypes.PC:
case JavaTypes.PC_UNTYPED:
Object frmpc = fetchObjectField(i);
if (frmpc == null && !nullLoaded)
return false;
OpenJPAStateManager tosm = manager.getBroker().getStateManager
(sm.fetchObjectField(i));
PersistenceCapable topc = (tosm == null) ? null
: tosm.getPersistenceCapable();
if (frmpc != null || topc != null) {
if (fmd.getCascadeAttach() == ValueMetaData.CASCADE_NONE)
frmpc = getReference(manager, frmpc, sm, fmd);
else {
PersistenceCapable intopc = topc;
if (!fmd.isEmbeddedPC() && frmpc != null && topc != null
&& !ObjectUtils.equals(topc.pcFetchObjectId(),
manager.getDetachedObjectId(frmpc))) {
intopc = null;
}