From 55fe85ba7456012e05d8d113ec023121e1656765 Mon Sep 17 00:00:00 2001 From: Yingjian Wu Date: Sat, 1 Jun 2024 23:39:10 -0700 Subject: [PATCH] fixTest --- .../MySqlParentChildRelMetaDataService.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java index 7a8667eab..b635994e6 100644 --- a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java +++ b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java @@ -100,26 +100,25 @@ public void createParentChildRelation(final QualifiedName parentName, @Override public void rename(final QualifiedName oldName, final QualifiedName newName) { try { - // Retry for renaming the Parent Entity - retryTemplate.execute((RetryCallback) context -> { - return jdbcTemplate.update(connection -> { + // Retry for renaming both Parent and Child Entities + retryTemplate.execute((RetryCallback) context -> { + jdbcTemplate.update(connection -> { // Rename Parent Entity - final PreparedStatement renameParentPS = connection.prepareStatement(SQL_RENAME_PARENT_ENTITY); - renameParentPS.setString(1, newName.toString()); - renameParentPS.setString(2, oldName.toString()); - return renameParentPS; - }); - }); + try (final PreparedStatement renameParentPS = connection.prepareStatement(SQL_RENAME_PARENT_ENTITY)) { + renameParentPS.setString(1, newName.toString()); + renameParentPS.setString(2, oldName.toString()); + renameParentPS.executeUpdate(); + } - // Retry for renaming the Child Entity - retryTemplate.execute((RetryCallback) context -> { - return jdbcTemplate.update(connection -> { // Rename Child Entity - final PreparedStatement renameChildPS = connection.prepareStatement(SQL_RENAME_CHILD_ENTITY); - renameChildPS.setString(1, newName.toString()); - renameChildPS.setString(2, oldName.toString()); - return renameChildPS; + try (final PreparedStatement renameChildPS = connection.prepareStatement(SQL_RENAME_CHILD_ENTITY)) { + renameChildPS.setString(1, newName.toString()); + renameChildPS.setString(2, oldName.toString()); + renameChildPS.executeUpdate(); + } + return null; }); + return null; }); } catch (RuntimeException e) { log.error("Failed to rename entity", e);