public class QueryTransformerRegex extends QueryParserRegex implements QueryTransformer
QueryTransformer
based on regular expressions.QueryParser.QueryPath
COND_PATTERN_REGEX, DISTINCT_PATTERN, DISTINCT_PATTERN_REGEX, ENTITY_PATH_ALIAS, ENTITY_PATH_PATTERN_REGEX, ENTITY_PATTERN, ENTITY_PATTERN_REGEX, EP_ALIAS, FEP_ALIAS, FEP_ENTITY, FROM_ENTITY_PATTERN, LAST_CLAUSE_PATTERN, LAST_CLAUSE_PATTERN_REGEX, OR_PATTERN, OR_PATTERN_REGEX, ORDER_BY_PATTERN, ORDER_BY_PATTERN_REGEX, PARAM_PATTERN, PARAM_PATTERN_REGEX, QS_ALIAS, QUERY_START_PATTERN, QUERY_START_PATTERN_REGEX, SELECT_DISTINCT_PATTERN, SELECT_DISTINCT_PATTERN_REGEX, source, WHERE_PATTERN, WHERE_PATTERN_REGEX
ALIAS_PLACEHOLDER, NAME
NAME
Constructor and Description |
---|
QueryTransformerRegex(java.lang.String source) |
Modifier and Type | Method and Description |
---|---|
void |
addDistinct()
Replaces 'select' with 'select distinct'.
|
void |
addEntityInGroupBy(java.lang.String entityAlias)
Adds @param entityAlias to 'group by' clause
|
void |
addFirstSelectionSource(java.lang.String selection) |
void |
addJoinAndWhere(java.lang.String join,
java.lang.String where)
Adds 'join' and 'where' clauses.
|
void |
addJoinAsIs(java.lang.String join)
Adds 'join' clause
|
void |
addOrderByIdIfNotExists(java.lang.String idProperty)
Adds 'order by' clause if it doesn't exists
|
void |
addWhere(java.lang.String where)
Adds 'where' clause replacing entity alias
|
void |
addWhereAsIs(java.lang.String where)
Adds 'where' clause
|
java.util.Set<java.lang.String> |
getAddedParams()
Get parameter names found during transformation
|
java.lang.String |
getResult()
Get buffer
|
void |
handleCaseInsensitiveParam(java.lang.String paramName) |
void |
mergeWhere(java.lang.String query)
Adds 'where' clause from the query provided.
|
boolean |
removeDistinct()
Replaces 'select distinct' with 'select'.
|
void |
removeOrderBy()
Removes 'order by' clause
|
void |
replaceEntityName(java.lang.String newName)
Replace main entity name, e.g.
|
void |
replaceInCondition(java.lang.String paramName) |
void |
replaceOrderBy(boolean desc,
java.lang.String... properties)
Adds or replaces 'order by' clause
|
void |
replaceWithCount()
Replaces
select e.f1, e.f2, ... clause with select count(e) ... |
void |
replaceWithSelectEntityVariable(java.lang.String selectEntityVariable)
Replaces
select e from ... clause with select 'selectEntityVariable' from ... |
void |
replaceWithSelectId()
Replaces
select e from ... clause with select e.id from ... |
void |
replaceWithSelectId(java.lang.String pkName)
Replaces
select e from ... clause with select e.pkName from ... |
void |
reset()
Reset internal buffer
|
getAllEntityNames, getEntityAlias, getEntityAlias, getEntityName, getOriginalEntityName, getOriginalEntityPath, getParamNames, getQueryPaths, hasIsNotNullCondition, hasIsNullCondition, isCollectionOriginalEntitySelect, isEntitySelect, isParameterInCondition, isQueryWithJoins
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
replaceIsNullStatements
isParameterUsedInAnyCondition
public void addWhere(java.lang.String where)
QueryTransformer
addWhere
in interface QueryTransformer
public void addWhereAsIs(java.lang.String where)
QueryTransformer
addWhereAsIs
in interface QueryTransformer
public void addJoinAsIs(java.lang.String join)
QueryTransformer
addJoinAsIs
in interface QueryTransformer
public void addJoinAndWhere(java.lang.String join, java.lang.String where)
QueryTransformer
addJoinAndWhere
in interface QueryTransformer
public void addFirstSelectionSource(java.lang.String selection)
addFirstSelectionSource
in interface QueryTransformer
public void mergeWhere(java.lang.String query)
QueryTransformer
mergeWhere
in interface QueryTransformer
public void replaceWithCount()
QueryTransformer
select e.f1, e.f2, ...
clause with select count(e) ...
replaceWithCount
in interface QueryTransformer
public void replaceWithSelectId()
QueryTransformer
select e from ...
clause with select e.id from ...
replaceWithSelectId
in interface QueryTransformer
public void replaceWithSelectId(java.lang.String pkName)
QueryTransformer
select e from ...
clause with select e.pkName from ...
replaceWithSelectId
in interface QueryTransformer
public void replaceWithSelectEntityVariable(java.lang.String selectEntityVariable)
QueryTransformer
select e from ...
clause with select 'selectEntityVariable' from ...
replaceWithSelectEntityVariable
in interface QueryTransformer
public boolean removeDistinct()
QueryTransformer
removeDistinct
in interface QueryTransformer
public void addDistinct()
QueryTransformer
addDistinct
in interface QueryTransformer
public void addOrderByIdIfNotExists(java.lang.String idProperty)
QueryTransformer
addOrderByIdIfNotExists
in interface QueryTransformer
public void replaceOrderBy(boolean desc, java.lang.String... properties)
QueryTransformer
replaceOrderBy
in interface QueryTransformer
public void addEntityInGroupBy(java.lang.String entityAlias)
QueryTransformer
addEntityInGroupBy
in interface QueryTransformer
public void removeOrderBy()
QueryTransformer
removeOrderBy
in interface QueryTransformer
public void replaceEntityName(java.lang.String newName)
QueryTransformer
replaceEntityName
in interface QueryTransformer
public void reset()
QueryTransformer
reset
in interface QueryTransformer
public java.lang.String getResult()
QueryTransformer
getResult
in interface QueryTransformer
public java.util.Set<java.lang.String> getAddedParams()
QueryTransformer
getAddedParams
in interface QueryTransformer
public void handleCaseInsensitiveParam(java.lang.String paramName)
handleCaseInsensitiveParam
in interface QueryTransformer
public void replaceInCondition(java.lang.String paramName)
replaceInCondition
in interface QueryTransformer