diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java index 0a4ed6bb..3ae2bfc8 100644 --- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java +++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java @@ -175,11 +175,14 @@ public void upgradeConnectorAndConfigs(MConnector mConnector, Connection conn) { private void updateConnectorAndDeleteConfigs(MConnector mConnector, Connection conn) { PreparedStatement updateConnectorStatement = null; PreparedStatement deleteConfig = null; + PreparedStatement deleteConfigDirection = null; PreparedStatement deleteInput = null; try { updateConnectorStatement = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_UPDATE_CONFIGURABLE); deleteInput = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_DELETE_INPUTS_FOR_CONFIGURABLE); + deleteConfigDirection = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_DELETE_DIRECTIONS_FOR_CONFIGURABLE); deleteConfig = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_DELETE_CONFIGS_FOR_CONFIGURABLE); + updateConnectorStatement.setString(1, mConnector.getUniqueName()); updateConnectorStatement.setString(2, mConnector.getClassName()); updateConnectorStatement.setString(3, mConnector.getVersion()); @@ -190,15 +193,17 @@ private void updateConnectorAndDeleteConfigs(MConnector mConnector, Connection c throw new SqoopException(CommonRepositoryError.COMMON_0035); } deleteInput.setLong(1, mConnector.getPersistenceId()); + deleteConfigDirection.setLong(1, mConnector.getPersistenceId()); deleteConfig.setLong(1, mConnector.getPersistenceId()); deleteInput.executeUpdate(); + deleteConfigDirection.executeUpdate(); deleteConfig.executeUpdate(); } catch (SQLException e) { logException(e, mConnector); throw new SqoopException(CommonRepositoryError.COMMON_0035, e); } finally { - closeStatements(updateConnectorStatement, deleteConfig, deleteInput); + closeStatements(updateConnectorStatement, deleteConfig, deleteConfigDirection, deleteInput); } } diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java index bff56a69..2102db96 100644 --- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java +++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java @@ -549,4 +549,11 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery { public static final String STMT_SELECT_SQ_CONFIG_DIRECTIONS = STMT_SELECT_SQ_CONFIG_DIRECTIONS_ALL + " WHERE " + COLUMN_SQ_CFG_DIR_CONFIG + " = ?"; + + // Delete the config directions for a connector + public static final String STMT_DELETE_DIRECTIONS_FOR_CONFIGURABLE = + "DELETE FROM " + TABLE_SQ_CONFIG_DIRECTIONS + + " WHERE " + COLUMN_SQ_CFG_DIR_CONFIG + + " IN (SELECT " + COLUMN_SQ_CFG_ID + " FROM " + TABLE_SQ_CONFIG + + " WHERE " + COLUMN_SQ_CFG_CONFIGURABLE + " = ?)"; }