class DBAccessorImpl implements DBAccessor {

  public String getCheckedForeignKey(String rawTableName, String rawForeignKeyName) throws SQLException {
    DatabaseMetaData metaData = getDatabaseMetaData();

    String tableName = convertObjectName(rawTableName);
    String foreignKeyName = convertObjectName(rawForeignKeyName);
    try (ResultSet rs = metaData.getImportedKeys(null, dbSchema, tableName)) {
      while (rs.next()) {
        String foundName = rs.getString("FK_NAME");
        if (StringUtils.equals(foreignKeyName, foundName)) {
          return foundName;
        }
      }
    }

    DatabaseType databaseType = configuration.getDatabaseType();
    if (databaseType == DatabaseType.ORACLE) {
      try (PreparedStatement ps = getConnection().prepareStatement("SELECT constraint_name FROM user_constraints WHERE table_name = ? AND constraint_type = 'R' AND constraint_name = ?")) {
        ps.setString(1, tableName);
        ps.setString(2, foreignKeyName);
        try (ResultSet rs = ps.executeQuery()) {
          if (rs.next()) {
            return foreignKeyName;
          }
        }
      }
    }

    LOG.warn("FK {} not found for table {}", foreignKeyName, tableName);

    return null;
  }

  @Inject public  DBAccessorImpl(Configuration configuration);

}