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;
}
Aggregations