RDBMSTableFKInfo tableFkInfo = (RDBMSTableFKInfo)handler.getSchemaData(conn, "foreign-keys",
new Object[] {this});
Iterator fksIter = tableFkInfo.getChildren().iterator();
while (fksIter.hasNext())
{
ForeignKeyInfo fkInfo = (ForeignKeyInfo)fksIter.next();
DatastoreIdentifier fkIdentifier;
String fkName = (String)fkInfo.getProperty("fk_name");
if (fkName == null)
{
fkIdentifier = idFactory.newForeignKeyIdentifier(this, foreignKeysByName.size());
}
else
{
fkIdentifier = idFactory.newIdentifier(IdentifierType.FOREIGN_KEY, fkName);
}
short deferrability = ((Short)fkInfo.getProperty("deferrability")).shortValue();
boolean initiallyDeferred = deferrability == DatabaseMetaData.importedKeyInitiallyDeferred;
ForeignKey fk = (ForeignKey) foreignKeysByName.get(fkIdentifier);
if (fk == null)
{
fk = new ForeignKey(initiallyDeferred);
fk.setName(fkIdentifier.getIdentifierName());
foreignKeysByName.put(fkIdentifier, fk);
}
String pkTableName = (String)fkInfo.getProperty("pk_table_name");
AbstractTable refTable = (AbstractTable)storeMgr.getDatastoreClass(
idFactory.newDatastoreContainerIdentifier(pkTableName));
if (refTable != null)
{
String fkColumnName = (String)fkInfo.getProperty("fk_column_name");
String pkColumnName = (String)fkInfo.getProperty("pk_column_name");
DatastoreIdentifier colName = idFactory.newIdentifier(IdentifierType.COLUMN, fkColumnName);
DatastoreIdentifier refColName = idFactory.newIdentifier(IdentifierType.COLUMN, pkColumnName);
DatastoreField col = columnsByName.get(colName);
DatastoreField refCol = refTable.columnsByName.get(refColName);
if (col != null && refCol != null)