java.lang.Object
org.miaixz.bus.mapper.handler.AbstractSqlHandler
org.miaixz.bus.pager.handler.SqlParserHandler
org.miaixz.bus.pager.handler.ConditionHandler
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Handler,org.miaixz.bus.mapper.handler.MapperHandler
- Direct Known Subclasses:
PermissionHandler,TenantHandler
public abstract class ConditionHandler
extends SqlParserHandler
implements org.miaixz.bus.mapper.handler.MapperHandler
Base class for handling multi-table conditions. Provides methods for processing SELECT, UPDATE, and DELETE statements
and appending conditions based on table metadata.
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler
DEFAULT_REFLECTOR_FACTORY, DELEGATE_BOUNDSQL, DELEGATE_BOUNDSQL_SQL, DELEGATE_MAPPEDSTATEMENT, MAPPEDSTATEMENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected net.sf.jsqlparser.expression.ExpressionandExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment) Handles the WHERE conditions for DELETE and UPDATE statements.protected net.sf.jsqlparser.expression.ExpressionappendExpression(net.sf.jsqlparser.expression.Expression expression, net.sf.jsqlparser.expression.Expression injectExpression) Appends a conditional expression.protected net.sf.jsqlparser.expression.ExpressionbuilderExpression(net.sf.jsqlparser.expression.Expression expression, List<net.sf.jsqlparser.schema.Table> tables, String segment) Builds and processes a conditional expression.abstract net.sf.jsqlparser.expression.ExpressionbuildTableExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String segment) Builds the query condition for a database table.protected voidprocessFunction(net.sf.jsqlparser.expression.Function function, String whereSegment) Processes a function, supporting `select fun(args..)` and nested functions `select fun1(fun2(args..),args..)`.protected voidprocessOtherFromItem(net.sf.jsqlparser.statement.select.FromItem fromItem, String whereSegment) Processes other FROM items (e.g., subqueries).protected voidprocessPlainSelect(net.sf.jsqlparser.statement.select.PlainSelect plainSelect, String whereSegment) Processes a PlainSelect statement, including its SELECT items, FROM item, and JOINs.protected voidprocessSelectBody(net.sf.jsqlparser.statement.select.Select selectBody, String whereSegment) Processes the body of a SELECT statement, applying the specified condition segment.protected voidprocessSelectItem(net.sf.jsqlparser.statement.select.SelectItem selectItem, String whereSegment) Processes subqueries or functions in a SELECT item.protected voidprocessWhereSubSelect(net.sf.jsqlparser.expression.Expression where, String whereSegment) Processes subqueries in the WHERE clause, supporting IN, =, >, <, >=, <=, <>, EXISTS, NOT EXISTS.Methods inherited from class org.miaixz.bus.pager.handler.SqlParserHandler
parse, parserMulti, parserSingle, parseStatements, processDelete, processInsert, processParser, processSelect, processUpdate, validateSqlMethods inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler
getMappedStatement, getMappedStatement, getMetaObject, getSqlParserInfo, mapperBoundSql, mapperStatementHandler, realTarget, setAdditionalParameterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.Handler
after, before, setPropertiesMethods inherited from interface org.miaixz.bus.mapper.handler.MapperHandler
getBoundSql, isQuery, isUpdate, prepare, query, update
-
Constructor Details
-
ConditionHandler
public ConditionHandler()
-
-
Method Details
-
processSelectBody
protected void processSelectBody(net.sf.jsqlparser.statement.select.Select selectBody, String whereSegment) Processes the body of a SELECT statement, applying the specified condition segment.- Parameters:
selectBody- the body of the SELECT statementwhereSegment- the full Mapper path, used for applying conditions
-
andExpression
protected net.sf.jsqlparser.expression.Expression andExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment) Handles the WHERE conditions for DELETE and UPDATE statements.- Parameters:
table- the Table objectwhere- the current WHERE conditionwhereSegment- the full Mapper path- Returns:
- the appended WHERE expression
-
processPlainSelect
protected void processPlainSelect(net.sf.jsqlparser.statement.select.PlainSelect plainSelect, String whereSegment) Processes a PlainSelect statement, including its SELECT items, FROM item, and JOINs.- Parameters:
plainSelect- the PlainSelect objectwhereSegment- the full Mapper path
-
processWhereSubSelect
protected void processWhereSubSelect(net.sf.jsqlparser.expression.Expression where, String whereSegment) Processes subqueries in the WHERE clause, supporting IN, =, >, <, >=, <=, <>, EXISTS, NOT EXISTS. Prerequisite: Subqueries must be in parentheses and usually on the right side of a comparison operator.- Parameters:
where- the WHERE conditionwhereSegment- the full Mapper path
-
processSelectItem
protected void processSelectItem(net.sf.jsqlparser.statement.select.SelectItem selectItem, String whereSegment) Processes subqueries or functions in a SELECT item.- Parameters:
selectItem- the SELECT itemwhereSegment- the full Mapper path
-
processFunction
Processes a function, supporting `select fun(args..)` and nested functions `select fun1(fun2(args..),args..)`.- Parameters:
function- the function expressionwhereSegment- the full Mapper path
-
processOtherFromItem
protected void processOtherFromItem(net.sf.jsqlparser.statement.select.FromItem fromItem, String whereSegment) Processes other FROM items (e.g., subqueries).- Parameters:
fromItem- the item in the FROM clausewhereSegment- the full Mapper path
-
builderExpression
protected net.sf.jsqlparser.expression.Expression builderExpression(net.sf.jsqlparser.expression.Expression expression, List<net.sf.jsqlparser.schema.Table> tables, String segment) Builds and processes a conditional expression.- Parameters:
expression- the current conditional expressiontables- the list of tablessegment- the full Mapper path- Returns:
- the constructed conditional expression
-
appendExpression
protected net.sf.jsqlparser.expression.Expression appendExpression(net.sf.jsqlparser.expression.Expression expression, net.sf.jsqlparser.expression.Expression injectExpression) Appends a conditional expression. By default, it appends to the end, but the position can be configured via `appendMode`.- Parameters:
expression- the original SQL conditional expressioninjectExpression- the conditional expression to be injected- Returns:
- the complete appended expression (for WHERE or ON clauses)
-
buildTableExpression
public abstract net.sf.jsqlparser.expression.Expression buildTableExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String segment) Builds the query condition for a database table.- Parameters:
table- the Table objectwhere- the current WHERE conditionsegment- the full Mapper path- Returns:
- the new query condition to be added (does not overwrite the original WHERE, only appends). Returns null if no new condition is added.
-