Package org.compiere.dbPort
Interface ISQLStatementRewriter
public interface ISQLStatementRewriter
IDEMPIERE-7023
OSGi extension point that lets a plugin pre-rewrite SQL statements before
Convert.convert() and dialect convertStatement() execute them.
Implementations must be registered via OSGi Declarative Services as
providers of this interface. The core iterates all registered services
and chains their rewriteStatements() in order.
Typical use cases: row-level multi-tenant SQL injection, audit logging,
PII masking at the SQL layer, transparent time-travel queries, custom
row-level security on top of OOTB ACL.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the output of this rewriter is cacheable.rewriteStatements(String sqlStatements) Rewrite a SQL statement.
-
Method Details
-
rewriteStatements
Rewrite a SQL statement.Contract: implementations must NOT execute SQL through the iDempiere DB layer (DB, Query, PO, etc.) inside this method. If the rewriter needs database-derived metadata (e.g. to decide whether a table has history enabled), that data must be loaded into a local cache before rewrite time and read from the cache here. Violating this contract causes re-entrant calls to
Convert.convertStatement()and aStackOverflowError.- Parameters:
sqlStatements- input SQL- Returns:
- possibly modified SQL to execute; if no rewrite is needed, return the parameter unchanged
-
rewriteIsCacheable
boolean rewriteIsCacheable()Whether the output of this rewriter is cacheable. Convert in DB_PostgreSQL maintains an in-memory Oracle->Postgres conversion cache: if this rewriter is dynamic (e.g. depends on a ThreadLocal context), return false to prevent stale cache entries.
-