diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLMandatoryElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLMandatoryElementHandler.java index 02cde5be95..027dd10baf 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLMandatoryElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLMandatoryElementHandler.java @@ -40,8 +40,10 @@ import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PackoutItem; import org.adempiere.pipo2.SQLElementParameters; import org.compiere.model.X_AD_Package_Imp_Detail; +import org.compiere.util.CacheMgt; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Util; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -89,6 +91,15 @@ public class SQLMandatoryElementHandler extends AbstractElementHandler { } logImportDetail (ctx, impDetail, 1, "SQLMandatory",count,"Execute"); ctx.packIn.getNotifier().addSuccessLine("-> " + sql); + // Cache Reset when deleting records via SQL + if (sql.toLowerCase().startsWith("delete from ")) { + String[] words = sql.split("[ \r\n]"); + String table = words[2]; + String tableName = DB.getSQLValueString(null, "SELECT TableName FROM AD_Table WHERE LOWER(TableName)=?", table.toLowerCase()); + if (! Util.isEmpty(tableName)) { + CacheMgt.get().reset(tableName); + } + } } catch (Exception e) { ctx.packIn.getNotifier().addFailureLine("SQL Mandatory failed, error (" + e.getLocalizedMessage() + "):"); logImportDetail (ctx, impDetail, 0, "SQLMandatory",-1,"Execute"); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLStatementElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLStatementElementHandler.java index 68e9ede7ed..02c7a4a91a 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLStatementElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/SQLStatementElementHandler.java @@ -31,9 +31,11 @@ import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PackoutItem; import org.adempiere.pipo2.SQLElementParameters; import org.compiere.model.X_AD_Package_Imp_Detail; +import org.compiere.util.CacheMgt; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Trx; +import org.compiere.util.Util; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -90,6 +92,15 @@ public class SQLStatementElementHandler extends AbstractElementHandler { } logImportDetail (ctx, impDetail, 1, "SQLStatement",count,"Execute"); ctx.packIn.getNotifier().addSuccessLine("-> " + sql); + // Cache Reset when deleting records via SQL + if (sql.toLowerCase().startsWith("delete from ")) { + String[] words = sql.split("[ \r\n]"); + String table = words[2]; + String tableName = DB.getSQLValueString(null, "SELECT TableName FROM AD_Table WHERE LOWER(TableName)=?", table.toLowerCase()); + if (! Util.isEmpty(tableName)) { + CacheMgt.get().reset(tableName); + } + } } catch (Exception e) { // rollback immediately on exception to avoid a wrong SQL stop the whole process if (savepoint != null)