Search in sources :

Example 26 with TypeManager

use of org.datanucleus.store.types.TypeManager in project datanucleus-rdbms by datanucleus.

the class EmbeddedPCMapping method getStateManagerForEmbeddedObject.

/**
 * Accessor for StateManager of the embedded PC object when provided with the owner object.
 * @param ownerSM StateManager of the owner
 * @return StateManager of the embedded object
 */
private DNStateManager getStateManagerForEmbeddedObject(DNStateManager ownerSM) {
    AbstractMemberMetaData theMmd = getRealMemberMetaData();
    // Owner (non-embedded) PC
    Object value = ownerSM.provideField(theMmd.getAbsoluteFieldNumber());
    TypeManager typeManager = ownerSM.getExecutionContext().getTypeManager();
    value = mmd.isSingleCollection() ? typeManager.getContainerAdapter(value).iterator().next() : value;
    if (value == null) {
        return null;
    }
    ExecutionContext ec = ownerSM.getExecutionContext();
    DNStateManager thisSM = ec.findStateManager(value);
    if (thisSM == null) {
        // Assign a StateManager to manage our embedded object
        thisSM = ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, value, false, ownerSM, theMmd.getAbsoluteFieldNumber(), objectType);
    }
    return thisSM;
}
Also used : ExecutionContext(org.datanucleus.ExecutionContext) TypeManager(org.datanucleus.store.types.TypeManager) DNStateManager(org.datanucleus.state.DNStateManager) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData)

Aggregations

TypeManager (org.datanucleus.store.types.TypeManager)26 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)10 JDOTypeConverter (org.datanucleus.api.jdo.JDOTypeConverter)8 ApiAdapter (org.datanucleus.api.ApiAdapter)6 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)5 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)5 RelationType (org.datanucleus.metadata.RelationType)5 ContainerHandler (org.datanucleus.store.types.ContainerHandler)5 AttributeConverter (javax.jdo.AttributeConverter)4 PersistenceNucleusContext (org.datanucleus.PersistenceNucleusContext)4 ExecutionContext (org.datanucleus.ExecutionContext)3 NucleusException (org.datanucleus.exceptions.NucleusException)3 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)3 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)3 EmbeddedMetaData (org.datanucleus.metadata.EmbeddedMetaData)3 FieldMetaData (org.datanucleus.metadata.FieldMetaData)3 FieldPersistenceModifier (org.datanucleus.metadata.FieldPersistenceModifier)3 ObjectProvider (org.datanucleus.state.ObjectProvider)3 MultiColumnConverter (org.datanucleus.store.types.converters.MultiColumnConverter)3 TypeConverter (org.datanucleus.store.types.converters.TypeConverter)3