private Object getObjectForApplicationId(final ExecutionContext ec, final Object resultSet,
final StatementClassMapping mappingDefinition, final int[] fieldNumbers,
Class pcClass, final AbstractClassMetaData cmd, boolean requiresInheritanceCheck,
final Object surrogateVersion)
{
final MappedStoreManager storeMgr = (MappedStoreManager)ec.getStoreManager();
Object id = getIdentityForResultSetRow(resultSet, mappingDefinition, ec, cmd, pcClass, requiresInheritanceCheck);
if (ec.getApiAdapter().isSingleFieldIdentity(id))
{
// Any single-field identity will have the precise target class determined above, so use it
pcClass = ec.getApiAdapter().getTargetClassForSingleFieldIdentity(id);
}
return ec.findObject(id, new FieldValues()
{
public void fetchFields(ObjectProvider sm)
{
FieldManager fm = storeMgr.getFieldManagerForResultProcessing(sm, resultSet, mappingDefinition);
sm.replaceFields(fieldNumbers, fm, false);
// Set version
if (surrogateVersion != null)
{
// Surrogate version field
sm.setVersion(surrogateVersion);
}
else if (cmd.getVersionMetaData() != null && cmd.getVersionMetaData().getFieldName() != null)
{
VersionMetaData vermd = cmd.getVersionMetaData();
// Version stored in a normal field
int versionFieldNumber = acmd.getMetaDataForMember(vermd.getFieldName()).getAbsoluteFieldNumber();
if (stmtMapping.getMappingForMemberPosition(versionFieldNumber) != null)
{
Object verFieldValue = sm.provideField(versionFieldNumber);
if (verFieldValue != null)
{
sm.setVersion(verFieldValue);
}
}
}
}
public void fetchNonLoadedFields(ObjectProvider sm)
{
FieldManager fm = storeMgr.getFieldManagerForResultProcessing(sm, resultSet, mappingDefinition);
sm.replaceNonLoadedFields(fieldNumbers, fm);
}
public FetchPlan getFetchPlanForLoading()
{
return fetchPlan;