Search in sources :

Example 41 with RelationType

use of org.datanucleus.metadata.RelationType in project datanucleus-core by datanucleus.

the class PersistFieldManager method storeObjectField.

/**
 * Method to store an object field.
 * @param fieldNumber Number of the field (absolute)
 * @param value Value of the field
 */
public void storeObjectField(int fieldNumber, Object value) {
    if (value != null) {
        if (replaceSCOsWithWrappers) {
            // Replace any SCO field that isn't already a wrapper, with its wrapper object
            boolean[] secondClassMutableFieldFlags = op.getClassMetaData().getSCOMutableMemberFlags();
            if (secondClassMutableFieldFlags[fieldNumber] && !(value instanceof SCO)) {
                // Replace the field with a SCO wrapper
                value = SCOUtils.wrapSCOField(op, fieldNumber, value, true);
            }
        }
        AbstractMemberMetaData mmd = op.getClassMetaData().getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
        if (mmd.isCascadePersist()) {
            ClassLoaderResolver clr = op.getExecutionContext().getClassLoaderResolver();
            RelationType relationType = mmd.getRelationType(clr);
            if (relationType != RelationType.NONE) {
                if (mmd.hasContainer()) {
                    processContainer(fieldNumber, value, mmd);
                } else {
                    // Process PC fields
                    if (mmd.isEmbedded() || mmd.isSerialized()) {
                        processPersistable(value, fieldNumber, ObjectProvider.EMBEDDED_PC);
                    } else {
                        processPersistable(value, -1, ObjectProvider.PC);
                    }
                }
            }
        }
    }
}
Also used : RelationType(org.datanucleus.metadata.RelationType) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData) SCO(org.datanucleus.store.types.SCO)

Aggregations

RelationType (org.datanucleus.metadata.RelationType)41 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)33 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)14 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)10 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)10 JavaTypeMapping (org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping)10 ArrayList (java.util.ArrayList)9 ExecutionContext (org.datanucleus.ExecutionContext)7 ApiAdapter (org.datanucleus.api.ApiAdapter)7 DatastoreClass (org.datanucleus.store.rdbms.table.DatastoreClass)7 ObjectProvider (org.datanucleus.state.ObjectProvider)6 Collection (java.util.Collection)5 Iterator (java.util.Iterator)5 List (java.util.List)5 NucleusException (org.datanucleus.exceptions.NucleusException)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Map (java.util.Map)4 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)4 EmbeddedPCMapping (org.datanucleus.store.rdbms.mapping.java.EmbeddedPCMapping)4