Package io.jmix.data.impl.jpql.transform
Class QueryTransformerAstBased
java.lang.Object
io.jmix.data.impl.jpql.transform.QueryTransformerAstBased
- All Implemented Interfaces:
QueryTransformer
@Scope("prototype")
@Component("data_QueryTransformer")
public class QueryTransformerAstBased
extends Object
implements QueryTransformer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DomainModelprotected Stringprotected QueryTreeAnalyzerprotected QueryTreeTransformerprotected QueryTreeFields inherited from interface io.jmix.data.QueryTransformer
ALIAS_PLACEHOLDER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidReplaces 'select' with 'select distinct'.voidaddEntityInGroupBy(String entityAlias) Adds @param entityAlias to 'group by' clausevoidaddFirstSelectionSource(String selection) voidAdds 'join' clausevoidaddJoinAndWhere(String join, String where) Adds 'join' and 'where' clauses.protected voidaddJoinInternal(String join, EntityVariable entityReference) voidaddOrderByIdIfNotExists(String pkName) Adds 'order by' clause if it doesn't existsvoidAdds 'where' clause replacing entity aliasvoidaddWhereAsIs(String where) Adds 'where' clauseprotected voidaddWhereInternal(org.antlr.runtime.tree.CommonTree whereTree) protected EntityVariableprotected EntityVariableGet parameter names found during transformationprotected QueryTreeAnalyzerGet bufferprotected QueryTreeTransformerprotected QueryTreegetTree()voidhandleCaseInsensitiveParam(String parameterName) protected List<JoinVariableNode>parseJoinCondition(String joinCondition) protected OrderByFieldNodeparseOrderByItem(String sortExpression) protected org.antlr.runtime.tree.CommonTreeparseSelectionSource(String selectionSource) protected org.antlr.runtime.tree.CommonTreeparseWhereCondition(String whereCondition) booleanReplaces 'select distinct' with 'select'.voidRemoves 'order by' clausevoidreplaceEntityName(String newName) Replace main entity name, e.g.protected StringreplaceEntityPlaceholder(String value, String variableName) voidreplaceInCondition(String parameterName) booleanreplaceIsNullStatements(String parameterName, boolean isNullValue) Replace allis nullandis not nullstatements with provided parametervoidreplaceOrderByExpressions(boolean directionDesc, String... sortExpressions) DEPRECATED.voidreplaceOrderByExpressions(Map<String, Sort.Direction> sortExpressions) Adds or replaces 'order by' clausevoidReplacesselect e.f1, e.f2, ...clause withselect count(e) ...voidreplaceWithSelectEntityVariable(String selectEntityVariable) Replacesselect e from ...clause withselect 'selectEntityVariable' from ...voidreplaceWithSelectId(String pkName) Replacesselect e from ...clause withselect e.pkName from ...voidreset()Reset internal buffer
-
Field Details
-
model
-
query
-
queryTree
-
queryTransformer
-
queryAnalyzer
-
addedParams
-
-
Constructor Details
-
QueryTransformerAstBased
-
-
Method Details
-
getTransformer
-
getAnalyzer
-
getTree
-
getResult
Description copied from interface:QueryTransformerGet buffer- Specified by:
getResultin interfaceQueryTransformer
-
getAddedParams
Description copied from interface:QueryTransformerGet parameter names found during transformation- Specified by:
getAddedParamsin interfaceQueryTransformer
-
handleCaseInsensitiveParam
- Specified by:
handleCaseInsensitiveParamin interfaceQueryTransformer
-
addWhere
Description copied from interface:QueryTransformerAdds 'where' clause replacing entity alias- Specified by:
addWherein interfaceQueryTransformer- Parameters:
where- - "{E}" may be used as a replaceable entity placeholder. No such value should be used as a string constant
-
addWhereAsIs
Description copied from interface:QueryTransformerAdds 'where' clause- Specified by:
addWhereAsIsin interfaceQueryTransformer
-
addJoin
Description copied from interface:QueryTransformerAdds 'join' clause- Specified by:
addJoinin interfaceQueryTransformer
-
addJoinAndWhere
Description copied from interface:QueryTransformerAdds 'join' and 'where' clauses. Replaces alias in 'join' but doesn't replace it in 'where'- Specified by:
addJoinAndWherein interfaceQueryTransformer
-
addFirstSelectionSource
- Specified by:
addFirstSelectionSourcein interfaceQueryTransformer
-
replaceWithCount
public void replaceWithCount()Description copied from interface:QueryTransformerReplacesselect e.f1, e.f2, ...clause withselect count(e) ...- Specified by:
replaceWithCountin interfaceQueryTransformer
-
replaceWithSelectId
Description copied from interface:QueryTransformerReplacesselect e from ...clause withselect e.pkName from ...- Specified by:
replaceWithSelectIdin interfaceQueryTransformer
-
replaceWithSelectEntityVariable
Description copied from interface:QueryTransformerReplacesselect e from ...clause withselect 'selectEntityVariable' from ...- Specified by:
replaceWithSelectEntityVariablein interfaceQueryTransformer
-
removeDistinct
public boolean removeDistinct()Description copied from interface:QueryTransformerReplaces 'select distinct' with 'select'.- Specified by:
removeDistinctin interfaceQueryTransformer- Returns:
- true if 'distinct' was really removed, false if there was no 'distinct' in the query
-
addDistinct
public void addDistinct()Description copied from interface:QueryTransformerReplaces 'select' with 'select distinct'.- Specified by:
addDistinctin interfaceQueryTransformer
-
replaceOrderByExpressions
Description copied from interface:QueryTransformerDEPRECATED. UseQueryTransformer.replaceOrderByExpressions(Map)- Specified by:
replaceOrderByExpressionsin interfaceQueryTransformer
-
replaceOrderByExpressions
Description copied from interface:QueryTransformerAdds or replaces 'order by' clause- Specified by:
replaceOrderByExpressionsin interfaceQueryTransformer
-
addOrderByIdIfNotExists
Description copied from interface:QueryTransformerAdds 'order by' clause if it doesn't exists- Specified by:
addOrderByIdIfNotExistsin interfaceQueryTransformer
-
addEntityInGroupBy
Description copied from interface:QueryTransformerAdds @param entityAlias to 'group by' clause- Specified by:
addEntityInGroupByin interfaceQueryTransformer
-
removeOrderBy
public void removeOrderBy()Description copied from interface:QueryTransformerRemoves 'order by' clause- Specified by:
removeOrderByin interfaceQueryTransformer
-
replaceEntityName
Description copied from interface:QueryTransformerReplace main entity name, e.g. "select d ref$Driver d" with "select d ref$ExtDriver d"- Specified by:
replaceEntityNamein interfaceQueryTransformer
-
reset
public void reset()Description copied from interface:QueryTransformerReset internal buffer- Specified by:
resetin interfaceQueryTransformer
-
replaceInCondition
- Specified by:
replaceInConditionin interfaceQueryTransformer
-
replaceIsNullStatements
Description copied from interface:QueryTransformerReplace allis nullandis not nullstatements with provided parameter- Specified by:
replaceIsNullStatementsin interfaceQueryTransformer- Parameters:
parameterName- name of the parameterisNullValue- is parameter value null- Returns:
trueif at least one statement was replaced,falseotherwise
-
parseWhereCondition
-
parseJoinCondition
-
parseSelectionSource
-
parseOrderByItem
-
replaceEntityPlaceholder
-
addWhereInternal
protected void addWhereInternal(org.antlr.runtime.tree.CommonTree whereTree) -
addJoinInternal
-
createMainIdentificationVariableNN
-
createMainSelectedPathNodeVariableNN
-