public class SqlQueryBuilder extends AbstractSqlLikeQueryBuilder implements QueryBuilder
QueryBuilder that builds SQL queries.AbstractSqlLikeQueryBuilder.Placeholder, AbstractSqlLikeQueryBuilder.PropertyPath, AbstractSqlLikeQueryBuilder.QueryHandler, AbstractSqlLikeQueryBuilder.QueryState| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
IN_EXPRESSION_START
The start of an IN expression.
|
AS_CLAUSE, CLOSE_BRACKET, COMMA, DELETE_CLAUSE, DOT, FROM_CLAUSE, FUNCTION_COUNT, LOGICAL_AND, LOGICAL_OR, NOT_CLAUSE, OPEN_BRACKET, ORDER_BY_CLAUSE, queryHandlers, SELECT_CLAUSE, SPACE, UPDATE_CLAUSE, WHERE_CLAUSE| Constructor and Description |
|---|
SqlQueryBuilder()
Default constructor.
|
SqlQueryBuilder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Constructor with annotation metadata.
|
SqlQueryBuilder(Dialect dialect) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
appendProjectionRowCount(java.lang.StringBuilder queryString,
java.lang.String logicalName)
Appends a row count projection to the query string.
|
java.lang.String |
buildBatchCreateTableStatement(PersistentEntity... entities)
Builds a batch create tables statement.
|
java.lang.String |
buildBatchDropTableStatement(PersistentEntity... entities)
Builds a batch drop tables statement.
|
java.lang.String[] |
buildCreateTableStatements(PersistentEntity entity)
Builds the create table statement.
|
java.lang.String[] |
buildDropTableStatements(PersistentEntity entity)
Builds the drop table statement.
|
QueryResult |
buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata,
PersistentEntity entity)
Builds an insert statement for the given entity.
|
protected java.lang.String[] |
buildJoin(java.lang.String alias,
JoinPath joinPath,
java.lang.String joinType,
java.lang.StringBuilder target,
java.util.Map<java.lang.String,java.lang.String> appliedJoinPaths)
Build a join expression for the given alias, association, join type and builder.
|
QueryResult |
buildPagination(Pageable pageable)
Encode the pageable.
|
protected 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 AbstractSqlLikeQueryBuilder.Placeholder |
formatParameter(int index)
Format the parameter at the given index.
|
protected java.lang.String |
getAliasName(PersistentEntity entity)
Get an alias name for the given entity.
|
java.lang.String |
getColumnName(PersistentProperty persistentProperty)
Get the column name for the given property.
|
protected java.lang.String |
getTableAsKeyword()
Get the AS keyword to use for table aliases.
|
java.lang.String |
getTableName(PersistentEntity entity)
Get the table name for the given entity.
|
protected boolean |
isAliasForBatch()
Should aliases be used in batch statements.
|
protected java.lang.String |
quote(java.lang.String persistedName)
Quote a column name for the dialect.
|
java.lang.String |
resolveJoinType(Join.Type jt)
Resolves the join type.
|
protected void |
selectAllColumns(AbstractSqlLikeQueryBuilder.QueryState queryState)
Obtain the string that selects all columns from the entity.
|
java.lang.String |
selectAllColumns(PersistentEntity entity,
java.lang.String alias)
Selects all columns for the given entity and alias.
|
protected GeneratedValue.Type |
selectAutoStrategy()
Selects the default fallback strategy.
|
appendDeleteClause, buildDelete, buildOrderBy, buildQuery, buildUpdate, getAliasName, getPathOnlyAliasName, handleSubQueryclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildDelete, buildOrderBy, buildQuery, buildUpdate, newQueryBuilderpublic static final java.lang.String IN_EXPRESSION_START
@Creator public SqlQueryBuilder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
annotationMetadata - The annotation metadatapublic SqlQueryBuilder()
public SqlQueryBuilder(Dialect dialect)
dialect - The dialect@NonNull
public java.lang.String buildBatchCreateTableStatement(@NonNull
PersistentEntity... entities)
entities - the entities@NonNull
public java.lang.String buildBatchDropTableStatement(@NonNull
PersistentEntity... entities)
entities - the entities@NonNull
public java.lang.String[] buildDropTableStatements(@NonNull
PersistentEntity entity)
entity - The entity@NonNull
public java.lang.String[] buildCreateTableStatements(@NonNull
PersistentEntity entity)
entity - The entityprotected java.lang.String getTableAsKeyword()
AbstractSqlLikeQueryBuildergetTableAsKeyword in class AbstractSqlLikeQueryBuilderprotected void selectAllColumns(AbstractSqlLikeQueryBuilder.QueryState queryState)
AbstractSqlLikeQueryBuilderselectAllColumns in class AbstractSqlLikeQueryBuilderqueryState - The query statepublic java.lang.String selectAllColumns(PersistentEntity entity, java.lang.String alias)
entity - The entityalias - The aliaspublic java.lang.String resolveJoinType(Join.Type jt)
AbstractSqlLikeQueryBuilderresolveJoinType in class AbstractSqlLikeQueryBuilderjt - The join type@Nullable public QueryResult buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity)
QueryBuilderbuildInsert in interface QueryBuilderrepositoryMetadata - The repository annotation metadataentity - The entity@NonNull public QueryResult buildPagination(@NonNull Pageable pageable)
QueryBuilderbuildPagination in interface QueryBuilderpageable - The pageableprotected void encodeInExpression(java.lang.StringBuilder whereClause,
AbstractSqlLikeQueryBuilder.Placeholder placeholder)
AbstractSqlLikeQueryBuilderencodeInExpression in class AbstractSqlLikeQueryBuilderwhereClause - The where clauseplaceholder - The placeholderprotected java.lang.String getAliasName(PersistentEntity entity)
AbstractSqlLikeQueryBuildergetAliasName in class AbstractSqlLikeQueryBuilderentity - The entitypublic java.lang.String getTableName(PersistentEntity entity)
AbstractSqlLikeQueryBuildergetTableName in class AbstractSqlLikeQueryBuilderentity - The entityprotected java.lang.String[] buildJoin(java.lang.String alias,
JoinPath joinPath,
java.lang.String joinType,
java.lang.StringBuilder target,
java.util.Map<java.lang.String,java.lang.String> appliedJoinPaths)
AbstractSqlLikeQueryBuilderbuildJoin in class AbstractSqlLikeQueryBuilderalias - The aliasjoinPath - The join pathjoinType - The join type stringtarget - The target builderappliedJoinPaths - The applied joins pathsprotected java.lang.String quote(java.lang.String persistedName)
persistedName - The persisted name.public java.lang.String getColumnName(PersistentProperty persistentProperty)
AbstractSqlLikeQueryBuildergetColumnName in class AbstractSqlLikeQueryBuilderpersistentProperty - The propertyprotected void appendProjectionRowCount(java.lang.StringBuilder queryString,
java.lang.String logicalName)
AbstractSqlLikeQueryBuilderappendProjectionRowCount in class AbstractSqlLikeQueryBuilderqueryString - The query stringlogicalName - The alias to the table nameprotected final boolean computePropertyPaths()
AbstractSqlLikeQueryBuildercomputePropertyPaths in class AbstractSqlLikeQueryBuilderprotected boolean isAliasForBatch()
AbstractSqlLikeQueryBuilderisAliasForBatch in class AbstractSqlLikeQueryBuilderprotected AbstractSqlLikeQueryBuilder.Placeholder formatParameter(int index)
AbstractSqlLikeQueryBuilderformatParameter in class AbstractSqlLikeQueryBuilderindex - The parameterprotected GeneratedValue.Type selectAutoStrategy()