Search in sources :

Example 1 with MakeTransientFieldManager

use of org.datanucleus.store.fieldmanager.MakeTransientFieldManager in project datanucleus-core by datanucleus.

the class StateManagerImpl method makeTransient.

/**
 * Method to change the object state to transient.
 * @param state Object containing the state of any fetchplan processing
 */
public void makeTransient(FetchPlanState state) {
    if ((flags & FLAG_MAKING_TRANSIENT) != 0) {
        // In the process of becoming transient
        return;
    }
    try {
        flags |= FLAG_MAKING_TRANSIENT;
        if (state == null) {
            // No FetchPlan in use so just unset the owner of all loaded SCO fields
            int[] fieldNumbers = ClassUtils.getFlagsSetTo(loadedFields, cmd.getSCOMutableMemberPositions(), true);
            if (fieldNumbers != null && fieldNumbers.length > 0) {
                provideFields(fieldNumbers, new UnsetOwnerFieldManager());
            }
        } else {
            // Make all loaded SCO fields transient appropriate to this fetch plan
            loadUnloadedFieldsInFetchPlan();
            int[] fieldNumbers = ClassUtils.getFlagsSetTo(loadedFields, cmd.getAllMemberPositions(), true);
            if (fieldNumbers != null && fieldNumbers.length > 0) {
                // TODO Fix this to just access the fields of the FieldManager yet this actually does a replaceField
                replaceFields(fieldNumbers, new MakeTransientFieldManager(this, cmd.getSCOMutableMemberFlags(), myFP, state));
            }
        }
        preStateChange();
        try {
            myLC = myLC.transitionMakeTransient(this, state != null, myEC.isRunningDetachAllOnCommit());
        } finally {
            postStateChange();
        }
    } finally {
        flags &= ~FLAG_MAKING_TRANSIENT;
    }
}
Also used : MakeTransientFieldManager(org.datanucleus.store.fieldmanager.MakeTransientFieldManager) UnsetOwnerFieldManager(org.datanucleus.store.fieldmanager.UnsetOwnerFieldManager)

Aggregations

MakeTransientFieldManager (org.datanucleus.store.fieldmanager.MakeTransientFieldManager)1 UnsetOwnerFieldManager (org.datanucleus.store.fieldmanager.UnsetOwnerFieldManager)1