use of org.datanucleus.metadata.AbstractMemberMetaData in project datanucleus-core by datanucleus.
the class L2CachePopulateFieldManager method storeDoubleField.
/* (non-Javadoc)
* @see org.datanucleus.store.fieldmanager.AbstractFieldManager#storeDoubleField(int, double)
*/
@Override
public void storeDoubleField(int fieldNumber, double value) {
AbstractMemberMetaData mmd = op.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
if (mmd.getPersistenceModifier() == FieldPersistenceModifier.TRANSACTIONAL) {
// Cannot cache transactional fields
cachedPC.setLoadedField(fieldNumber, false);
return;
}
if (!mmd.isCacheable()) {
// Field is marked as not cacheable so unset its loaded flag and return null
cachedPC.setLoadedField(fieldNumber, false);
return;
}
cachedPC.setLoadedField(fieldNumber, true);
cachedPC.setFieldValue(fieldNumber, value);
}
use of org.datanucleus.metadata.AbstractMemberMetaData in project datanucleus-core by datanucleus.
the class L2CachePopulateFieldManager method storeCharField.
/* (non-Javadoc)
* @see org.datanucleus.store.fieldmanager.AbstractFieldManager#storeCharField(int, char)
*/
@Override
public void storeCharField(int fieldNumber, char value) {
AbstractMemberMetaData mmd = op.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
if (mmd.getPersistenceModifier() == FieldPersistenceModifier.TRANSACTIONAL) {
// Cannot cache transactional fields
cachedPC.setLoadedField(fieldNumber, false);
return;
}
if (!mmd.isCacheable()) {
// Field is marked as not cacheable so unset its loaded flag and return null
cachedPC.setLoadedField(fieldNumber, false);
return;
}
cachedPC.setLoadedField(fieldNumber, true);
cachedPC.setFieldValue(fieldNumber, value);
}
use of org.datanucleus.metadata.AbstractMemberMetaData in project datanucleus-core by datanucleus.
the class L2CachePopulateFieldManager method storeFloatField.
/* (non-Javadoc)
* @see org.datanucleus.store.fieldmanager.AbstractFieldManager#storeFloatField(int, float)
*/
@Override
public void storeFloatField(int fieldNumber, float value) {
AbstractMemberMetaData mmd = op.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
if (mmd.getPersistenceModifier() == FieldPersistenceModifier.TRANSACTIONAL) {
// Cannot cache transactional fields
cachedPC.setLoadedField(fieldNumber, false);
return;
}
if (!mmd.isCacheable()) {
// Field is marked as not cacheable so unset its loaded flag and return null
cachedPC.setLoadedField(fieldNumber, false);
return;
}
cachedPC.setLoadedField(fieldNumber, true);
cachedPC.setFieldValue(fieldNumber, value);
}
use of org.datanucleus.metadata.AbstractMemberMetaData in project datanucleus-core by datanucleus.
the class L2CacheRetrieveFieldManager method fetchObjectField.
/* (non-Javadoc)
* @see org.datanucleus.store.fieldmanager.AbstractFieldManager#fetchObjectField(int)
*/
@Override
public Object fetchObjectField(int fieldNumber) {
Object value = cachedPC.getFieldValue(fieldNumber);
if (value == null) {
return null;
}
AbstractMemberMetaData mmd = op.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
return mmd.hasContainer() ? processContainerField(fieldNumber, value, mmd) : processField(fieldNumber, value, mmd);
}
use of org.datanucleus.metadata.AbstractMemberMetaData in project datanucleus-core by datanucleus.
the class TypeManagerImpl method wrapAndReplaceSCOField.
/**
* Method to create a new SCO wrapper for the specified field replacing the old value with the new value.
* If the member value is a SCO already will just return the (new) value.
* @param ownerOP The ObjectProvider of the owner object
* @param memberNumber The member number in the owner
* @param newValue The value to initialise the wrapper with (if any) for this member
* @param oldValue The previous value that we are replacing with this value
* @param replaceFieldIfChanged Whether to replace the member in the object if wrapping the value
* @return The wrapper (or original value if not wrappable)
*/
public Object wrapAndReplaceSCOField(ObjectProvider ownerOP, int memberNumber, Object newValue, Object oldValue, boolean replaceFieldIfChanged) {
if (newValue == null || !ownerOP.getClassMetaData().getSCOMutableMemberFlags()[memberNumber]) {
// We don't wrap null objects currently
return newValue;
}
if (!(newValue instanceof SCO) || ownerOP.getObject() != ((SCO) newValue).getOwner()) {
// Not a SCO wrapper, or is a SCO wrapper but not owned by this object
AbstractMemberMetaData mmd = ownerOP.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(memberNumber);
if (replaceFieldIfChanged) {
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("026029", StringUtils.toJVMIDString(ownerOP.getObject()), ownerOP.getExecutionContext() != null ? IdentityUtils.getPersistableIdentityForId(ownerOP.getInternalObjectId()) : ownerOP.getInternalObjectId(), mmd.getName()));
}
}
if (newValue != null && newValue instanceof SCO) {
// Passed in value is a wrapper type already, so just return it!
if (replaceFieldIfChanged) {
// Replace the field with this value
ownerOP.replaceField(mmd.getAbsoluteFieldNumber(), newValue);
}
return newValue;
}
// Create new wrapper of the required type
Class requiredType = newValue.getClass();
SCO sco = createSCOInstance(ownerOP, mmd, requiredType);
if (replaceFieldIfChanged) {
// Replace the field in the owner with the wrapper before initialising it
ownerOP.replaceField(mmd.getAbsoluteFieldNumber(), sco);
}
// Initialise the SCO for use, providing new and old values so the wrapper has the ability to do something intelligent
sco.initialise(newValue, oldValue);
return sco;
}
return newValue;
}
Aggregations