sql.append(')');
return sql.toString();
}
private void addForeignKeyConstraint(JDBCAbstractCMRFieldBridge cmrField) {
JDBCRelationshipRoleMetaData metaData = cmrField.getMetaData();
if (metaData.hasForeignKeyConstraint()) {
if (metaData.getRelationMetaData().isTableMappingStyle()) {
addForeignKeyConstraint(manager.getDataSource(metaData.getRelationMetaData().getDataSourceName()), // TODO: jeb - get datasource
cmrField.getQualifiedTableName(),
cmrField.getFieldName(),
cmrField.getTableKeyFields(),
cmrField.getEntity().getQualifiedTableName(),
cmrField.getEntity().getPrimaryKeyFields());
} else if (cmrField.hasForeignKey()) {
JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity();
addForeignKeyConstraint(cmrField.getEntity().getDataSource(),
cmrField.getEntity().getQualifiedTableName(),
cmrField.getFieldName(),
cmrField.getForeignKeyFields(),
relatedEntity.getQualifiedTableName(),
relatedEntity.getPrimaryKeyFields());
}
} else {
log.debug("Foreign key constraint not added as requested: relationshipRolename=" + metaData.getRelationshipRoleName());
}
}