// Create the basic statement (without any selected columns)
QueryExpression stmt = getGetStatement(sm,key);
// Add the required field selections to the statement
ResultObjectFactory rof = newResultObjectFactory(sm, stmt, false, true);
ObjectManager om = sm.getObjectManager();
Transaction tx = om.getTransaction();
boolean useUpdateLock = ((Boolean)tx.getOptions().get("transaction.serializeReadObjects")).booleanValue();
String statement = storeMgr.getStatementTextForQuery(stmt, useUpdateLock);
Object value=null;
try
{
ManagedConnection mconn = storeMgr.getConnection(om);
SQLController sqlControl = storeMgr.getSQLController();
try
{
PreparedStatement ps = storeMgr.getStatementForQuery(stmt, om, mconn, useUpdateLock, null, null);
try
{
ResultSet rs = sqlControl.executeStatementQuery(mconn, statement, ps);
try
{
boolean found = rs.next();
if (!found)
{
throw new NoSuchElementException();
}
if (valuesAreEmbedded || valuesAreSerialised)
{
int param[] = new int[valueMapping.getNumberOfDatastoreFields()];
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 = -1;
if (mapTable != null)
{
ownerFieldNumber = ((JoinTable)mapTable).getOwnerFieldMetaData().getAbsoluteFieldNumber();
}
value = valueMapping.getObject(om, rs, param, sm, ownerFieldNumber);
}
else
{
// Value = Non-PC
value = valueMapping.getObject(om, rs, param);
}
}
else if (valueMapping instanceof ReferenceMapping)
{
// Value = Reference (Interface/Object)
int param[] = new int[valueMapping.getNumberOfDatastoreFields()];
for (int i = 0; i < param.length; ++i)
{
param[i] = i + 1;
}
value = valueMapping.getObject(om, rs, param);
}
else
{
// Value = PC
value = rof.getObject(om, rs);
}
SQLWarnings.log(rs);
}
finally