// is it a view ?
Table table= TableUtils.getTable(database, tableName);
if (table==null)
table = TableUtils.getView(database, tableName);
Column column = ColumnUtils.getColumn(table, columnName);
// is it a view
Table foreignTable= TableUtils.getTable(database, foreignTableName);
if (foreignTable==null)
foreignTable = TableUtils.getView(database, foreignTableName);
String foreignColumnName = field.getLinkToTargetField();
if (foreignColumnName==null)
foreignColumnName = TableUtils.getPrimaryKey(foreignTable);
Column foreignColumn = ColumnUtils.getColumn(foreignTable, foreignColumnName);
if (table!=null && column != null && foreignTable!=null && foreignColumn!=null) {
reference.setLocalTable(table);
reference.setLocalColumn(column);
reference.getLocalColumn().setAlias(reference.getLocalColumn().getAlias());