code: private void updateForeignKeys(EntityMetadata metadata, Object id, List<RelationHolder> relationHolders)
      {
          for (RelationHolder rh : relationHolders)
          {
              String linkName = rh.getRelationName();
              Object linkValue = rh.getRelationValue();
              if (linkName != null && linkValue != null)
              {
  
                  // String fieldName = metadata.getFieldName(linkName);
  
                  String clause = getFromClause(metadata.getSchema(), metadata.getTableName());
                  // String updateSql = "Update " +
                  // metadata.getEntityClazz().getSimpleName() + " SET " +
                  // fieldName + "= '" + linkValue + "' WHERE "
                  // + ((AbstractAttribute) metadata.getIdAttribute()).getName() +
                  // " = '" + id + "'";
  
                  String updateSql = "Update " + clause + " SET " + linkName + "= '" + linkValue + "' WHERE "
                          + ((AbstractAttribute) metadata.getIdAttribute()).getJPAColumnName() + " = '" + id + "'";
  
                  onNativeUpdate(updateSql, null);
              }
          }
      }
docs: Updates foreign keys into master table.
  
  @param metadata
  the metadata
  @param id
  the id
  @param relationHolders
  the relation holders