IDEMPIERE-5726 2Pack: TableElementHandler should reset Table cache after commit of transaction (#1843)

This commit is contained in:
hengsin 2023-05-20 09:50:13 +08:00 committed by GitHub
parent d2426c5ebd
commit c05d2cefa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -45,8 +45,10 @@ import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.model.X_AD_Package_Imp_Detail;
import org.compiere.model.X_AD_Table;
import org.compiere.process.DatabaseViewValidate;
import org.compiere.util.CacheMgt;
import org.compiere.util.Env;
import org.compiere.util.Trx;
import org.compiere.util.TrxEventListener;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@ -123,6 +125,27 @@ public class TableElementHandler extends AbstractElementHandler {
throw new DatabaseAccessException("Failed to validate view for " + mTable.getName());
}
}
Trx trx = Trx.get(getTrxName(ctx), false);
if (trx != null && !mTable.isView()) {
trx.addTrxEventListener(new TrxEventListener() {
@Override
public void afterRollback(Trx trx, boolean success) {
}
@Override
public void afterCommit(Trx trx, boolean success) {
if (success) {
CacheMgt.get().reset(MTable.Table_Name, mTable.get_ID());
}
}
@Override
public void afterClose(Trx trx) {
}
});
}
}
private int validateDatabaseView(PIPOContext ctx, MTable table)