String stmt = (tx.lockReadObjects() ? getStmtLocked : getStmtUnlocked);
Object value = null;
try
{
RDBMSStoreManager storeMgr = (RDBMSStoreManager)this.storeMgr;
ManagedConnection mconn = storeMgr.getConnection(ec);
SQLController sqlControl = storeMgr.getSQLController();
try
{
// Create the statement and supply owner/key params
PreparedStatement ps = sqlControl.getStatementForQuery(mconn, stmt);
StatementMappingIndex ownerIdx = getMappingParams.getMappingForParameter("owner");
int numParams = ownerIdx.getNumberOfParameterOccurrences();
for (int paramInstance=0;paramInstance<numParams;paramInstance++)
{
ownerIdx.getMapping().setObject(ec, ps,
ownerIdx.getParameterPositionsForOccurrence(paramInstance), ownerSM.getObject());
}
StatementMappingIndex keyIdx = getMappingParams.getMappingForParameter("key");
numParams = keyIdx.getNumberOfParameterOccurrences();
for (int paramInstance=0;paramInstance<numParams;paramInstance++)
{
keyIdx.getMapping().setObject(ec, ps,
keyIdx.getParameterPositionsForOccurrence(paramInstance), key);
}
try
{
ResultSet rs = sqlControl.executeStatementQuery(mconn, stmt, ps);
try
{
boolean found = rs.next();
if (!found)
{
throw new NoSuchElementException();
}
if (valuesAreEmbedded || valuesAreSerialised)
{
int param[] = new int[valueMapping.getNumberOfDatastoreMappings()];
for (int i = 0; i < param.length; ++i)
{
param[i] = i + 1;
}
if (valueMapping instanceof SerialisedPCMapping ||
valueMapping instanceof SerialisedReferenceMapping ||
valueMapping instanceof EmbeddedKeyPCMapping)
{
// Value = Serialised
int ownerFieldNumber = ((JoinTable)mapTable).getOwnerMemberMetaData().getAbsoluteFieldNumber();
value = valueMapping.getObject(ec, rs, param, ownerSM, ownerFieldNumber);
}
else
{
// Value = Non-PC
value = valueMapping.getObject(ec, rs, param);
}
}
else if (valueMapping instanceof ReferenceMapping)
{
// Value = Reference (Interface/Object)
int param[] = new int[valueMapping.getNumberOfDatastoreMappings()];
for (int i = 0; i < param.length; ++i)
{
param[i] = i + 1;
}
value = valueMapping.getObject(ec, rs, param);
}
else
{
// Value = PC
ResultObjectFactory rof = storeMgr.newResultObjectFactory(vmd,
getMappingDef, false, null, clr.classForName(valueType));
value = rof.getObject(ec, rs);
}
JDBCUtils.logWarnings(rs);
}
finally
{
rs.close();
}
}
finally
{
sqlControl.closeStatement(mconn, ps);
}
}
finally
{
mconn.release();
}
}
catch (SQLException e)
{
throw new NucleusDataStoreException(LOCALISER.msg("056014", stmt), e);