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 |
VARIABLE_PATTERN
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.
|
protected void |
appendUpdateSetParameter(java.lang.StringBuilder queryString,
PersistentProperty prop,
AbstractSqlLikeQueryBuilder.Placeholder param)
Appends the SET=? call to the query string.
|
QueryResult |
buildDelete(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
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,
AbstractSqlLikeQueryBuilder.QueryState queryState)
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(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
QueryModel query)
Encode the given query for the passed annotation metadata and query.
|
QueryResult |
buildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
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 java.lang.String |
formatEndsWith() |
protected abstract AbstractSqlLikeQueryBuilder.Placeholder |
formatParameter(int index)
Format the parameter at the given index.
|
protected java.lang.String |
formatStartsWith() |
protected java.lang.String |
formatStartsWithBeginning() |
protected java.lang.String |
formEndsWithEnd() |
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 java.lang.String |
getUnescapedTableName(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.
|
protected boolean |
isExpandEmbedded()
Should embedded queries by expanded by the implementation.
|
protected java.lang.String |
quote(java.lang.String persistedName)
Quote a column name for the dialect.
|
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.
|
protected boolean |
shouldEscape(PersistentEntity entity)
Whether queries should be escaped for the given entity.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildDelete, buildInsert, buildPagination, buildQuery, buildUpdate, newQueryBuilder, shouldAliasProjections
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 java.lang.String formEndsWithEnd()
protected java.lang.String formatStartsWithBeginning()
protected java.lang.String formatEndsWith()
protected java.lang.String formatStartsWith()
protected void encodeInExpression(java.lang.StringBuilder whereClause, AbstractSqlLikeQueryBuilder.Placeholder placeholder)
whereClause
- The where clauseplaceholder
- The placeholderpublic QueryResult buildQuery(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query)
QueryBuilder
buildQuery
in interface QueryBuilder
annotationMetadata
- The annotation metadataquery
- The query modelprotected abstract java.lang.String getTableName(PersistentEntity entity)
entity
- The entityprotected java.lang.String getUnescapedTableName(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, AbstractSqlLikeQueryBuilder.QueryState queryState)
alias
- The aliasjoinPath
- The join pathjoinType
- The join type stringstringBuilder
- The target builderappliedJoinPaths
- The applied joins pathsqueryState
- The query stateprotected abstract java.lang.String getColumnName(PersistentProperty persistentProperty)
persistentProperty
- The propertyprotected abstract void selectAllColumns(AbstractSqlLikeQueryBuilder.QueryState queryState)
queryState
- The query stateprotected boolean shouldEscape(@NonNull PersistentEntity entity)
entity
- The entityprotected java.lang.String getTableAsKeyword()
protected java.lang.String quote(java.lang.String persistedName)
persistedName
- The persisted name.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 boolean isExpandEmbedded()
protected void appendUpdateSetParameter(java.lang.StringBuilder queryString, PersistentProperty prop, AbstractSqlLikeQueryBuilder.Placeholder param)
queryString
- The query stringprop
- The propertyparam
- the parameterprotected abstract boolean computePropertyPaths()
public QueryResult buildUpdate(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query, @NonNull java.util.List<java.lang.String> propertiesToUpdate)
QueryBuilder
buildUpdate
in interface QueryBuilder
annotationMetadata
- The annotation metadataquery
- The querypropertiesToUpdate
- The property names to updatepublic QueryResult buildDelete(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query)
QueryBuilder
buildDelete
in interface QueryBuilder
annotationMetadata
- The annotation metadataquery
- 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