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
Modifier and TypeFieldDescriptionprotected DomainModel
protected String
protected QueryTreeAnalyzer
protected QueryTreeTransformer
protected QueryTree
Fields inherited from interface io.jmix.data.QueryTransformer
ALIAS_PLACEHOLDER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Replaces 'select' with 'select distinct'.void
addEntityInGroupBy
(String entityAlias) Adds @param entityAlias to 'group by' clausevoid
addFirstSelectionSource
(String selection) void
Adds 'join' clausevoid
addJoinAndWhere
(String join, String where) Adds 'join' and 'where' clauses.protected void
addJoinInternal
(String join, EntityVariable entityReference) void
addOrderByIdIfNotExists
(String pkName) Adds 'order by' clause if it doesn't existsvoid
Adds 'where' clause replacing entity aliasvoid
addWhereAsIs
(String where) Adds 'where' clauseprotected void
addWhereInternal
(org.antlr.runtime.tree.CommonTree whereTree) protected EntityVariable
protected EntityVariable
Get parameter names found during transformationprotected QueryTreeAnalyzer
Get bufferprotected QueryTreeTransformer
protected QueryTree
getTree()
void
handleCaseInsensitiveParam
(String parameterName) protected List<JoinVariableNode>
parseJoinCondition
(String joinCondition) protected OrderByFieldNode
parseOrderByItem
(String sortExpression) protected org.antlr.runtime.tree.CommonTree
parseSelectionSource
(String selectionSource) protected org.antlr.runtime.tree.CommonTree
parseWhereCondition
(String whereCondition) boolean
Replaces 'select distinct' with 'select'.void
Removes 'order by' clausevoid
replaceEntityName
(String newName) Replace main entity name, e.g.protected String
replaceEntityPlaceholder
(String value, String variableName) void
replaceInCondition
(String parameterName) boolean
replaceIsNullStatements
(String parameterName, boolean isNullValue) Replace allis null
andis not null
statements with provided parametervoid
replaceOrderByExpressions
(Map<String, Sort.Direction> sortExpressions) Adds or replaces 'order by' clausevoid
Replacesselect e.f1, e.f2, ...
clause withselect count(e) ...
void
replaceWithSelectEntityVariable
(String selectEntityVariable) Replacesselect e from ...
clause withselect 'selectEntityVariable' from ...
void
replaceWithSelectId
(String pkName) Replacesselect e from ...
clause withselect e.pkName from ...
void
reset()
Reset internal buffer
-
Field Details
-
model
-
query
-
queryTree
-
queryTransformer
-
queryAnalyzer
-
addedParams
-
-
Constructor Details
-
QueryTransformerAstBased
-
-
Method Details
-
getTransformer
-
getAnalyzer
-
getTree
-
getResult
Description copied from interface:QueryTransformer
Get buffer- Specified by:
getResult
in interfaceQueryTransformer
-
getAddedParams
Description copied from interface:QueryTransformer
Get parameter names found during transformation- Specified by:
getAddedParams
in interfaceQueryTransformer
-
handleCaseInsensitiveParam
- Specified by:
handleCaseInsensitiveParam
in interfaceQueryTransformer
-
addWhere
Description copied from interface:QueryTransformer
Adds 'where' clause replacing entity alias- Specified by:
addWhere
in 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:QueryTransformer
Adds 'where' clause- Specified by:
addWhereAsIs
in interfaceQueryTransformer
-
addJoin
Description copied from interface:QueryTransformer
Adds 'join' clause- Specified by:
addJoin
in interfaceQueryTransformer
-
addJoinAndWhere
Description copied from interface:QueryTransformer
Adds 'join' and 'where' clauses. Replaces alias in 'join' but doesn't replace it in 'where'- Specified by:
addJoinAndWhere
in interfaceQueryTransformer
-
addFirstSelectionSource
- Specified by:
addFirstSelectionSource
in interfaceQueryTransformer
-
replaceWithCount
public void replaceWithCount()Description copied from interface:QueryTransformer
Replacesselect e.f1, e.f2, ...
clause withselect count(e) ...
- Specified by:
replaceWithCount
in interfaceQueryTransformer
-
replaceWithSelectId
Description copied from interface:QueryTransformer
Replacesselect e from ...
clause withselect e.pkName from ...
- Specified by:
replaceWithSelectId
in interfaceQueryTransformer
-
replaceWithSelectEntityVariable
Description copied from interface:QueryTransformer
Replacesselect e from ...
clause withselect 'selectEntityVariable' from ...
- Specified by:
replaceWithSelectEntityVariable
in interfaceQueryTransformer
-
removeDistinct
public boolean removeDistinct()Description copied from interface:QueryTransformer
Replaces 'select distinct' with 'select'.- Specified by:
removeDistinct
in 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:QueryTransformer
Replaces 'select' with 'select distinct'.- Specified by:
addDistinct
in interfaceQueryTransformer
-
replaceOrderByExpressions
Description copied from interface:QueryTransformer
Adds or replaces 'order by' clause- Specified by:
replaceOrderByExpressions
in interfaceQueryTransformer
-
addOrderByIdIfNotExists
Description copied from interface:QueryTransformer
Adds 'order by' clause if it doesn't exists- Specified by:
addOrderByIdIfNotExists
in interfaceQueryTransformer
-
addEntityInGroupBy
Description copied from interface:QueryTransformer
Adds @param entityAlias to 'group by' clause- Specified by:
addEntityInGroupBy
in interfaceQueryTransformer
-
removeOrderBy
public void removeOrderBy()Description copied from interface:QueryTransformer
Removes 'order by' clause- Specified by:
removeOrderBy
in interfaceQueryTransformer
-
replaceEntityName
Description copied from interface:QueryTransformer
Replace main entity name, e.g. "select d ref$Driver d" with "select d ref$ExtDriver d"- Specified by:
replaceEntityName
in interfaceQueryTransformer
-
reset
public void reset()Description copied from interface:QueryTransformer
Reset internal buffer- Specified by:
reset
in interfaceQueryTransformer
-
replaceInCondition
- Specified by:
replaceInCondition
in interfaceQueryTransformer
-
replaceIsNullStatements
Description copied from interface:QueryTransformer
Replace allis null
andis not null
statements with provided parameter- Specified by:
replaceIsNullStatements
in interfaceQueryTransformer
- Parameters:
parameterName
- name of the parameterisNullValue
- is parameter value null- Returns:
true
if at least one statement was replaced,false
otherwise
-
parseWhereCondition
-
parseJoinCondition
-
parseSelectionSource
-
parseOrderByItem
-
replaceEntityPlaceholder
-
addWhereInternal
protected void addWhereInternal(org.antlr.runtime.tree.CommonTree whereTree) -
addJoinInternal
-
createMainIdentificationVariableNN
-
createMainSelectedPathNodeVariableNN
-