use of org.datanucleus.store.rdbms.mapping.java.SerialisedPCMapping in project datanucleus-rdbms by datanucleus.
the class ResultSetGetter method fetchObjectField.
public Object fetchObjectField(int fieldNumber) {
StatementMappingIndex mapIdx = resultMappings.getMappingForMemberPosition(fieldNumber);
JavaTypeMapping mapping = mapIdx.getMapping();
AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
RelationType relationType = mmd.getRelationType(ec.getClassLoaderResolver());
Object value;
if (mapping instanceof EmbeddedPCMapping || mapping instanceof SerialisedPCMapping || mapping instanceof SerialisedReferenceMapping) {
value = mapping.getObject(ec, rs, mapIdx.getColumnPositions(), op, fieldNumber);
} else {
if (mmd.isSingleCollection()) {
StatementClassMapping relationMappings = resultMappings.getMappingDefinitionForMemberPosition(fieldNumber);
if (relationMappings != null) {
Class type = ec.getClassLoaderResolver().classForName(mmd.getCollection().getElementType());
value = processSubObjectFields(mapping, type, relationMappings);
ElementContainerHandler containerHandler = ec.getTypeManager().getContainerHandler(mmd.getType());
value = containerHandler.newContainer(mmd, value);
} else {
value = mapping.getObject(ec, rs, mapIdx.getColumnPositions());
}
} else if (RelationType.isRelationSingleValued(relationType)) {
// Process fields of sub-object if available in this result set
StatementClassMapping relationMappings = resultMappings.getMappingDefinitionForMemberPosition(fieldNumber);
if (relationMappings != null) {
value = processSubObjectFields(mapping, mmd.getType(), relationMappings);
} else {
value = mapping.getObject(ec, rs, mapIdx.getColumnPositions());
}
} else {
value = mapping.getObject(ec, rs, mapIdx.getColumnPositions());
}
}
if (op != null) {
if (cmd.getSCOMutableMemberFlags()[fieldNumber]) {
// Wrap any SCO mutable fields
return SCOUtils.wrapSCOField(op, fieldNumber, value, false);
} else if (RelationType.isRelationSingleValued(relationType) && (mmd.getEmbeddedMetaData() != null && mmd.getEmbeddedMetaData().getOwnerMember() != null)) {
// Embedded PC, so make sure the field is wrapped where appropriate TODO This should be part of ManagedRelationships
op.updateOwnerFieldInEmbeddedField(fieldNumber, value);
return value;
}
}
return value;
}
Aggregations