String tablename = foreignKeys[i].getForeignTableName();
Table table2 = TableUtils.getTable(database,tablename);
String columnName = null;
if (ref!=null)
columnName = ref.getForeignColumnName();
Column column2 = ColumnUtils.getColumn (table2, columnName);
//reference = new Reference(table2, ColumnUtils.getColumn(table2, ref.getLocalColumnName()), tablename, ref.getLocalColumnName());
reference = new Reference(table2, column2, tablename, columnName);
reference.setLocalColumn(ref.getLocalColumn());
//logger.info("table = "+tablename+", columnName = "+columnName);