public abstract class AbstractSqlLikeQueryBuilder extends java.lang.Object implements QueryBuilder
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractSqlLikeQueryBuilder.Placeholder
Represents a placeholder in query.
|
protected class |
AbstractSqlLikeQueryBuilder.PropertyPath
Represents a path to a property.
|
protected static interface |
AbstractSqlLikeQueryBuilder.QueryHandler
A query handler.
|
protected class |
AbstractSqlLikeQueryBuilder.QueryState
The state of the query.
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
AS_CLAUSE |
protected static char |
CLOSE_BRACKET |
protected static char |
COMMA |
protected static java.lang.String |
DELETE_CLAUSE |
protected static char |
DOT |
protected static java.lang.String |
FROM_CLAUSE |
protected static java.lang.String |
FUNCTION_COUNT |
protected static java.lang.String |
LOGICAL_AND |
protected static java.lang.String |
LOGICAL_OR |
protected static java.lang.String |
NOT_CLAUSE |
protected static char |
OPEN_BRACKET |
static java.lang.String |
ORDER_BY_CLAUSE |
protected java.util.Map<java.lang.Class,AbstractSqlLikeQueryBuilder.QueryHandler> |
queryHandlers |
protected static java.lang.String |
SELECT_CLAUSE |
protected static char |
SPACE |
protected static java.lang.String |
UPDATE_CLAUSE |
protected static java.lang.String |
WHERE_CLAUSE |
Constructor and Description |
---|
AbstractSqlLikeQueryBuilder() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.StringBuilder |
appendDeleteClause(java.lang.StringBuilder queryString)
Append the delete clause.
|
protected abstract void |
appendProjectionRowCount(java.lang.StringBuilder queryString,
java.lang.String logicalName)
Appends a row count projection to the query string.
|
QueryResult |
buildDelete(QueryModel query)
Encode the given query into the encoded query instance.
|
protected abstract java.lang.String[] |
buildJoin(java.lang.String alias,
JoinPath joinPath,
java.lang.String joinType,
java.lang.StringBuilder stringBuilder,
java.util.Map<java.lang.String,java.lang.String> appliedJoinPaths)
Build a join expression for the given alias, association, join type and builder.
|
QueryResult |
buildOrderBy(PersistentEntity entity,
Sort sort)
Encode the given query into the encoded query instance.
|
QueryResult |
buildQuery(QueryModel query)
Encode the given query into the encoded query instance.
|
QueryResult |
buildUpdate(QueryModel query,
java.util.List<java.lang.String> propertiesToUpdate)
Encode the given query into the encoded query instance.
|
protected abstract boolean |
computePropertyPaths()
Whether property path expressions require computation by the implementation.
|
protected void |
encodeInExpression(java.lang.StringBuilder whereClause,
AbstractSqlLikeQueryBuilder.Placeholder placeholder)
Placeholders for IN queries in SQL require special treatment.
|
protected abstract AbstractSqlLikeQueryBuilder.Placeholder |
formatParameter(int index)
Format the parameter at the given index.
|
java.lang.String |
getAliasName(JoinPath joinPath)
Get the alias name.
|
protected java.lang.String |
getAliasName(PersistentEntity entity)
Get an alias name for the given entity.
|
protected abstract java.lang.String |
getColumnName(PersistentProperty persistentProperty)
Get the column name for the given property.
|
protected java.lang.String |
getPathOnlyAliasName(JoinPath joinPath)
Get the alias name for just the join path.
|
protected java.lang.String |
getTableAsKeyword()
Get the AS keyword to use for table aliases.
|
protected abstract java.lang.String |
getTableName(PersistentEntity entity)
Get the table name for the given entity.
|
protected void |
handleSubQuery(AbstractSqlLikeQueryBuilder.QueryState queryState,
QueryModel.SubqueryCriterion subqueryCriterion,
java.lang.String comparisonExpression)
For handling subqueries.
|
protected abstract boolean |
isAliasForBatch()
Should aliases be used in batch statements.
|
abstract java.lang.String |
resolveJoinType(Join.Type jt)
Resolves the join type.
|
protected abstract void |
selectAllColumns(AbstractSqlLikeQueryBuilder.QueryState queryState)
Obtain the string that selects all columns from the entity.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildInsert, buildPagination, newQueryBuilder
public static final java.lang.String ORDER_BY_CLAUSE
protected static final java.lang.String SELECT_CLAUSE
protected static final java.lang.String AS_CLAUSE
protected static final java.lang.String FROM_CLAUSE
protected static final java.lang.String WHERE_CLAUSE
protected static final char COMMA
protected static final char CLOSE_BRACKET
protected static final char OPEN_BRACKET
protected static final char SPACE
protected static final char DOT
protected static final java.lang.String NOT_CLAUSE
protected static final java.lang.String LOGICAL_AND
protected static final java.lang.String UPDATE_CLAUSE
protected static final java.lang.String DELETE_CLAUSE
protected static final java.lang.String LOGICAL_OR
protected static final java.lang.String FUNCTION_COUNT
protected final java.util.Map<java.lang.Class,AbstractSqlLikeQueryBuilder.QueryHandler> queryHandlers
protected void encodeInExpression(java.lang.StringBuilder whereClause, AbstractSqlLikeQueryBuilder.Placeholder placeholder)
whereClause
- The where clauseplaceholder
- The placeholder@NonNull public QueryResult buildQuery(@NonNull QueryModel query)
QueryBuilder
buildQuery
in interface QueryBuilder
query
- The queryprotected abstract java.lang.String getTableName(PersistentEntity entity)
entity
- The entityprotected java.lang.String getAliasName(PersistentEntity entity)
entity
- The entitypublic java.lang.String getAliasName(JoinPath joinPath)
joinPath
- The join path@NonNull protected java.lang.String getPathOnlyAliasName(JoinPath joinPath)
joinPath
- The join pathprotected abstract java.lang.String[] buildJoin(java.lang.String alias, JoinPath joinPath, java.lang.String joinType, java.lang.StringBuilder stringBuilder, java.util.Map<java.lang.String,java.lang.String> appliedJoinPaths)
alias
- The aliasjoinPath
- The join pathjoinType
- The join type stringstringBuilder
- The target builderappliedJoinPaths
- The applied joins pathsprotected abstract java.lang.String getColumnName(PersistentProperty persistentProperty)
persistentProperty
- The propertyprotected abstract void selectAllColumns(AbstractSqlLikeQueryBuilder.QueryState queryState)
queryState
- The query stateprotected java.lang.String getTableAsKeyword()
protected abstract void appendProjectionRowCount(java.lang.StringBuilder queryString, java.lang.String logicalName)
queryString
- The query stringlogicalName
- The alias to the table nameprotected void handleSubQuery(AbstractSqlLikeQueryBuilder.QueryState queryState, QueryModel.SubqueryCriterion subqueryCriterion, java.lang.String comparisonExpression)
queryState
- The query statesubqueryCriterion
- The subquery criterioncomparisonExpression
- The comparison expressionprotected abstract boolean computePropertyPaths()
@NonNull public QueryResult buildUpdate(@NonNull QueryModel query, java.util.List<java.lang.String> propertiesToUpdate)
QueryBuilder
buildUpdate
in interface QueryBuilder
query
- The querypropertiesToUpdate
- The property names to update@NonNull public QueryResult buildDelete(@NonNull QueryModel query)
QueryBuilder
buildDelete
in interface QueryBuilder
query
- The queryprotected abstract boolean isAliasForBatch()
@NonNull protected java.lang.StringBuilder appendDeleteClause(java.lang.StringBuilder queryString)
queryString
- The query string@NonNull public QueryResult buildOrderBy(@NonNull PersistentEntity entity, @NonNull Sort sort)
QueryBuilder
buildOrderBy
in interface QueryBuilder
entity
- The root entitysort
- The sortprotected abstract AbstractSqlLikeQueryBuilder.Placeholder formatParameter(int index)
index
- The parameterpublic abstract java.lang.String resolveJoinType(Join.Type jt)
jt
- The join type