Class JpaQueryBuilder
java.lang.Object
io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder
io.micronaut.data.model.query.builder.jpa.JpaQueryBuilder
- All Implemented Interfaces:
- QueryBuilder
Builds JPA 1.0 String-based queries from the Query model.
- Since:
- 1.0
- Author:
- Graeme Rocher
- 
Nested Class SummaryNested classes/interfaces inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilderAbstractSqlLikeQueryBuilder.CriteriaContext, AbstractSqlLikeQueryBuilder.CriterionHandler<T extends QueryModel.Criterion>, AbstractSqlLikeQueryBuilder.Placeholder, AbstractSqlLikeQueryBuilder.QueryPosition, AbstractSqlLikeQueryBuilder.QueryPropertyPath, AbstractSqlLikeQueryBuilder.QueryState
- 
Field SummaryFields inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilderALIAS_REPLACE, ALIAS_REPLACE_QUOTED, AND, AS_CLAUSE, AVG, CLOSE_BRACKET, COMMA, COUNT_DISTINCT, DELETE_CLAUSE, DISTINCT, DOT, EQUALS, EQUALS_FALSE, EQUALS_TRUE, FROM_CLAUSE, FUNCTION_COUNT, GREATER_THAN, GREATER_THAN_OR_EQUALS, IS_EMPTY, IS_NOT_EMPTY, IS_NOT_NULL, IS_NULL, JSON_COLUMN, LESS_THAN, LESS_THAN_OR_EQUALS, LOGICAL_AND, LOGICAL_OR, MAX, MIN, NOT, NOT_EQUALS, OPEN_BRACKET, OR, ORDER_BY_CLAUSE, queryHandlers, SELECT_CLAUSE, SPACE, SUM, UPDATE_CLAUSE, WHERE_CLAUSEFields inherited from interface io.micronaut.data.model.query.builder.QueryBuilderVARIABLE_PATTERN
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected @NonNull StringBuilderappendDeleteClause(StringBuilder queryString) Append the delete clause.protected voidappendProjectionRowCount(StringBuilder queryString, String logicalName) Appends a row count projection to the query string.protected StringbuildAdditionalWhereClause(AbstractSqlLikeQueryBuilder.QueryState queryState, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds additional where clause if there isWhereannotation on the entity.@Nullable QueryResultbuildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Builds an insert statement for the given entity.protected String[]buildJoin(String alias, JoinPath joinPath, String joinType, StringBuilder target, Map<String, String> appliedJoinPaths, AbstractSqlLikeQueryBuilder.QueryState queryState) Build a join expression for the given alias, association, join type and builder.@NonNull QueryResultbuildPagination(@NonNull Pageable pageable) Encode the pageable.protected final booleanWhether property path expressions require computation by the implementation.protected AbstractSqlLikeQueryBuilder.PlaceholderformatParameter(int index) Format the parameter at the given index.getAliasName(PersistentEntity entity) Get an alias name for the given entity.protected StringgetColumnName(PersistentProperty persistentProperty) Get the column name for the given property.protected StringgetTableName(PersistentEntity entity) Get the table name for the given entity.protected booleanisAliasForBatch(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Should aliases be used in batch statements.protected StringQuote a column name for the dialect.Resolves the join type.protected voidselectAllColumns(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, PersistentEntity entity, String alias, StringBuilder queryBuffer) Selects all columns for the given entity and alias.protected voidselectAllColumns(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer) Obtain the string that selects all columns from the entity.Methods inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilderaddCriterionHandler, appendAssociationProjection, appendForUpdate, appendOrder, appendPropertyRef, appendTransformed, appendUpdateSetParameter, asLiteral, asLiterals, asPath, buildAdditionalWhereString, buildAdditionalWhereString, buildDelete, buildOrderBy, buildOrderBy, buildQuery, buildSelect, buildUpdate, buildUpdate, buildWhereClause, checkDialectSupportsJsonEntity, concat, getAliasName, getColumnAlias, getDataTransformerReadValue, getDataTransformerWriteValue, getDialect, getMappedName, getMappedName, getMappedName, getNamingStrategy, getNamingStrategy, getPathOnlyAliasName, getTableAsKeyword, getUnescapedTableName, handleSubQuery, isExpandEmbedded, isJsonEntity, newBindingContext, resolveWhereForAnnotationMetadata, selectAllColumns, selectAllColumnsFromJoinPaths, shouldEscape, traversePersistentProperties, traversePersistentProperties, traversePersistentProperties, traversePersistentPropertiesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.data.model.query.builder.QueryBuilderbuildDelete, buildDelete, buildOrderBy, buildQuery, buildUpdate, buildUpdate, buildUpdate, buildUpdate, shouldAliasProjections, supportsForUpdate
- 
Constructor Details- 
JpaQueryBuilderpublic JpaQueryBuilder()Default constructor.
 
- 
- 
Method Details- 
quoteDescription copied from class:AbstractSqlLikeQueryBuilderQuote a column name for the dialect.- Overrides:
- quotein class- AbstractSqlLikeQueryBuilder
- Parameters:
- persistedName- The persisted name.
- Returns:
- The quoted name
 
- 
getAliasNameDescription copied from class:AbstractSqlLikeQueryBuilderGet an alias name for the given entity.- Overrides:
- getAliasNamein class- AbstractSqlLikeQueryBuilder
- Parameters:
- entity- The entity
- Returns:
- The alias name
 
- 
buildJoinprotected String[] buildJoin(String alias, JoinPath joinPath, String joinType, StringBuilder target, Map<String, String> appliedJoinPaths, AbstractSqlLikeQueryBuilder.QueryState queryState) Description copied from class:AbstractSqlLikeQueryBuilderBuild a join expression for the given alias, association, join type and builder.- Specified by:
- buildJoinin class- AbstractSqlLikeQueryBuilder
- Parameters:
- alias- The alias
- joinPath- The join path
- joinType- The join type string
- target- The target builder
- appliedJoinPaths- The applied joins paths
- queryState- The query state
- Returns:
- An array representing the aliases for each join association in the specified join path
 
- 
buildAdditionalWhereClauseprotected String buildAdditionalWhereClause(AbstractSqlLikeQueryBuilder.QueryState queryState, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Description copied from class:AbstractSqlLikeQueryBuilderBuilds additional where clause if there isWhereannotation on the entity.- Overrides:
- buildAdditionalWhereClausein class- AbstractSqlLikeQueryBuilder
- Parameters:
- queryState- the query state
- annotationMetadata- the annotation metadata
- Returns:
- where clause if there was Whereannotation on the entity (or joins for JPA implementation)
 
- 
getTableNameDescription copied from class:AbstractSqlLikeQueryBuilderGet the table name for the given entity.- Specified by:
- getTableNamein class- AbstractSqlLikeQueryBuilder
- Parameters:
- entity- The entity
- Returns:
- The table name
 
- 
getColumnNameDescription copied from class:AbstractSqlLikeQueryBuilderGet the column name for the given property.- Specified by:
- getColumnNamein class- AbstractSqlLikeQueryBuilder
- Parameters:
- persistentProperty- The property
- Returns:
- The column name
 
- 
selectAllColumnsprotected void selectAllColumns(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer) Description copied from class:AbstractSqlLikeQueryBuilderObtain the string that selects all columns from the entity.- Specified by:
- selectAllColumnsin class- AbstractSqlLikeQueryBuilder
- Parameters:
- annotationMetadata- The annotation metadata
- queryState- The query state
 
- 
selectAllColumnsprotected void selectAllColumns(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, PersistentEntity entity, String alias, StringBuilder queryBuffer) Description copied from class:AbstractSqlLikeQueryBuilderSelects all columns for the given entity and alias.- Specified by:
- selectAllColumnsin class- AbstractSqlLikeQueryBuilder
- Parameters:
- annotationMetadata- The annotation metadata
- entity- The entity
- alias- The alias
- queryBuffer- The buffer to append the columns
 
- 
appendProjectionRowCountDescription copied from class:AbstractSqlLikeQueryBuilderAppends a row count projection to the query string.- Specified by:
- appendProjectionRowCountin class- AbstractSqlLikeQueryBuilder
- Parameters:
- queryString- The query string
- logicalName- The alias to the table name
 
- 
computePropertyPathsprotected final boolean computePropertyPaths()Description copied from class:AbstractSqlLikeQueryBuilderWhether property path expressions require computation by the implementation. In a certain query dialects property paths are supported (such as JPA-QL where you can do select foo.bar) whilst for explicit SQL queries paths like this have to be computed into aliases / column name references.- Specified by:
- computePropertyPathsin class- AbstractSqlLikeQueryBuilder
- Returns:
- True if property path computation is required.
 
- 
isAliasForBatchprotected boolean isAliasForBatch(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Description copied from class:AbstractSqlLikeQueryBuilderShould aliases be used in batch statements.- Specified by:
- isAliasForBatchin class- AbstractSqlLikeQueryBuilder
- Parameters:
- persistentEntity- the persistent entity
- annotationMetadata- the method annotation metadata
- Returns:
- True if they should
 
- 
formatParameterDescription copied from class:AbstractSqlLikeQueryBuilderFormat the parameter at the given index.- Specified by:
- formatParameterin class- AbstractSqlLikeQueryBuilder
- Parameters:
- index- The parameter
- Returns:
- The index
 
- 
resolveJoinTypeDescription copied from class:AbstractSqlLikeQueryBuilderResolves the join type.- Specified by:
- resolveJoinTypein class- AbstractSqlLikeQueryBuilder
- Parameters:
- jt- The join type
- Returns:
- The join type.
 
- 
buildInsert@Nullable public @Nullable QueryResult buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Description copied from interface:QueryBuilderBuilds an insert statement for the given entity.- Specified by:
- buildInsertin interface- QueryBuilder
- Parameters:
- repositoryMetadata- The repository annotation metadata
- entity- The entity
- Returns:
- The insert statement or null if the implementation doesn't require insert statements
 
- 
appendDeleteClauseDescription copied from class:AbstractSqlLikeQueryBuilderAppend the delete clause.- Overrides:
- appendDeleteClausein class- AbstractSqlLikeQueryBuilder
- Parameters:
- queryString- The query string
- Returns:
- The delete clause
 
- 
buildPaginationDescription copied from interface:QueryBuilderEncode the pageable.- Specified by:
- buildPaginationin interface- QueryBuilder
- Parameters:
- pageable- The pageable
- Returns:
- The encoded query
 
 
-