ClassMetaData ownerMeta = ownerSm.getMetaData();
// loop through all the fields in the owner entity
for (FieldMetaData ownerFM : ownerMeta.getFields()) {
// look for any single column in this field references the
// same column as the foreign key target column
Column cols[] = ((FieldMapping) ownerFM).getColumns();
if (cols.length == 1 // only support attribute of non-compound foreign key
&& cols != ownerCols // not @Id field
&& cols[0].getIdentifier().equals(ownerCols[0].getIdentifier())) {
// copy the foreign key value to the current field.
FieldMetaData inverseFM = inverseSm.getMetaData().getField(