{
if (fmd.isPrimaryKey())
{
Integer abs_field_num = new Integer(fmd.getAbsoluteFieldNumber());
int parametersIndex[] = new int[m.getNumberOfDatastoreFields()];
StatementExpressionIndex sei = new StatementExpressionIndex();
sei.setMapping(m);
sei.setParameterIndex(parametersIndex);
mappingStatementIndex.getPrimaryKeys()[fmd.getAbsoluteFieldNumber()] = sei;
for (int j=0; j<parametersIndex.length; j++)
{
if (where.length() > 0)
{
where.append(" AND ");
}
String condition = m.getDataStoreMapping(j).getDatastoreField().getIdentifier() +
"=" + ((RDBMSMapping)m.getDataStoreMapping(j)).getUpdateInputParameter();
where.append(condition);
if (!pkFields.contains(abs_field_num))
{
pkFields.add(abs_field_num);
}
parametersIndex[j] = paramIndex++;
}
}
else if (m instanceof PersistenceCapableMapping || m instanceof ReferenceMapping)
{
if (m.getNumberOfDatastoreFields() == 0)
{
// Field storing a PC object with FK at other side
int relationType = fmd.getRelationType(clr);
if (relationType == Relation.ONE_TO_ONE_BI)
{
if (fmd.getMappedBy() != null)
{
// 1-1 bidirectional field without datastore column(s) (with single FK at other side)
oneToOneNonOwnerFields.add(fmd);
}
}
else if (relationType == Relation.MANY_TO_ONE_BI)
{
AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
if (fmd.getJoinMetaData() != null || relatedMmds[0].getJoinMetaData() != null)
{
// 1-N bidirectional using join table for relation
// TODO Anything to do here ?
}
}
}
}
else
{
if (whereClauseConsumption)
{
// Must be version field since nothing else should come through here
int parametersIndex[] = new int[m.getNumberOfDatastoreFields()];
parametersIndex[0] = paramIndex++;
StatementExpressionIndex sei = new StatementExpressionIndex();
sei.setMapping(m);
sei.setParameterIndex(parametersIndex);
mappingStatementIndex.setVersion2(sei);
String inputParam = ((RDBMSMapping)m.getDataStoreMapping(0)).getUpdateInputParameter();
String condition = " AND " + m.getDataStoreMapping(0).getDatastoreField().getIdentifier() + "=" + inputParam;
where.append(condition);
}