This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 573de5613b40f1f55b18268d66516c6a9e2e30dc Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 23 18:58:35 2016 +0200 Correction de la suppression des données --- .../topia/service/sql/batch/actions/DeleteTablesAction.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java index ba71564..8b3397b 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java @@ -44,6 +44,8 @@ import java.util.List; */ public class DeleteTablesAction extends AbstractTablesAction<DeleteTablesRequest> { + public static final String DELETE_ASSOCIATION_STATEMENT = "DELETE FROM %s.%s WHERE %s = '%%s';\n"; + public static final String DELETE_STATEMENT = "DELETE FROM %s.%s WHERE topiaId = '%%s';\n"; /** * Logger. @@ -67,6 +69,10 @@ public class DeleteTablesAction extends AbstractTablesAction<DeleteTablesRequest String topiaIdColumnName = TopiaEntity.PROPERTY_TOPIA_ID.toLowerCase(); int topiaIdColumnIndex = columnNames.indexOf(topiaIdColumnName) + 1; + if (table.isAssociationTable()) { + topiaIdColumnIndex = 1; + } + boolean useOutputWriter = useOutputWriter(); boolean useOutputDb = useOutputDb(); @@ -132,7 +138,12 @@ public class DeleteTablesAction extends AbstractTablesAction<DeleteTablesRequest protected String newDeleteStatementSql(TopiaSqlTable table) { - String sql = String.format(DELETE_STATEMENT, table.getSchemaName(), table.getTableName()); + String sql; + if (table.isAssociationTable()) { + sql = String.format(DELETE_ASSOCIATION_STATEMENT, table.getSchemaName(), table.getTableName(), table.getJoinColumnName()); + } else { + sql = String.format(DELETE_STATEMENT, table.getSchemaName(), table.getTableName()); + } if (log.isDebugEnabled()) { log.debug("Delete sql: " + sql); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.