Class AbstractSqlLikeQueryBuilder2
java.lang.Object
io.micronaut.data.model.query.builder.sql.AbstractSqlLikeQueryBuilder2
- All Implemented Interfaces:
QueryBuilder2
- Direct Known Subclasses:
JpaQueryBuilder2,SqlQueryBuilder2
@Internal
public abstract class AbstractSqlLikeQueryBuilder2
extends Object
implements QueryBuilder2
An abstract class for builders that build SQL-like queries.
- Since:
- 1.0.0
- Author:
- graemerocher, Denis Stepanov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic final recordRepresents a placeholder in query.protected static final recordprotected static enumprotected classRepresents a path to a property.protected final classThe state of the query.protected classThe predicate visitor to construct the query.protected classThe selection visitor to construct the query.Nested classes/interfaces inherited from interface io.micronaut.data.model.query.builder.QueryBuilder2
QueryBuilder2.BaseQueryDefinition, QueryBuilder2.DeleteQueryDefinition, QueryBuilder2.InsertQueryDefinition, QueryBuilder2.SelectQueryDefinition, QueryBuilder2.UpdateQueryDefinition -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final charprotected static final charprotected static final Stringprotected static final charprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final charprotected static final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final charprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull StringBuilderappendDeleteClause(StringBuilder queryString) Append the delete clause.protected final voidappendExpression(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, jakarta.persistence.criteria.Expression<?> expression, boolean isProjection) protected voidappendForUpdate(AbstractSqlLikeQueryBuilder2.QueryPosition queryPosition, QueryBuilder2.SelectQueryDefinition definition, StringBuilder queryBuilder) Adds "forUpdate" pessimistic locking.protected voidappendLimitAndOffset(Dialect dialect, long limit, long offset, StringBuilder builder) Append limit and offset.protected voidappendLimitAndOrder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.SelectQueryDefinition definition, boolean appendLimit, boolean appendOrder, AbstractSqlLikeQueryBuilder2.QueryState queryState) protected voidappendOrder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, List<jakarta.persistence.criteria.Order> orders, AbstractSqlLikeQueryBuilder2.QueryState queryState) Appends order to the query.protected final voidappendPropertyRef(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, PersistentPropertyPath pp, boolean isProjection) protected voidappendTransformed(StringBuilder sb, String transformed, Runnable appendParameter) Appends custom query part.protected voidappendUpdateSetParameter(StringBuilder sb, String alias, PersistentProperty prop, Runnable appendParameter) Appends the SET=? call to the query string.protected @NonNull StringConvert the literal value to it's SQL representation.protected static StringasPath(List<Association> associations, PersistentProperty property) Join associations and property as path.protected final AbstractSqlLikeQueryBuilder2.QueryPropertyPathasQueryPropertyPath(String tableAlias, PersistentProperty persistentProperty) protected StringbuildAdditionalWhereClause(AbstractSqlLikeQueryBuilder2.QueryState queryState, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds additional where clause if there isWhereannotation on the entity.protected final StringbuildAdditionalWhereString(JoinPath joinPath, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds WHERE clause based onWhereannotation on the metadata.protected StringbuildAdditionalWhereString(String alias, PersistentEntity entity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds WHERE clause for the entity and given alias ifIgnoreWhereis not present.buildDelete(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryBuilder2.DeleteQueryDefinition definition) Encode the given query into the encoded query instance.protected voidbuildJoin(String joinType, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, PersistentAssociationPath joinAssociation, PersistentEntity associationOwner, String currentJoinAlias, String lastJoinAlias) Build a join expression for the given alias, association, join type and builder.buildLimitAndOffset(long limit, long offset) Generate the limit and offset query.@NonNull StringbuildOrderBy(String query, @NonNull PersistentEntity entity, @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull Sort sort, boolean nativeQuery, @Nullable String tableAlias) Encode the given query into the encoded query instance.buildPropertyByName(@NonNull String propertyName, @NonNull String query, @NonNull PersistentEntity entity, @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, boolean nativeQuery, @Nullable String tableAlias) Encode the given property retrieval into a query instance.protected final @NonNull AbstractSqlLikeQueryBuilder2.QueryStatebuildQuery(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.SelectQueryDefinition definition, AbstractSqlLikeQueryBuilder2.QueryBuilder queryBuilder, boolean appendLimit, boolean appendOrder, @Nullable String tableAliasPrefix) buildSelect(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.SelectQueryDefinition definition) Encode the given query for the passed annotation metadata and query.protected voidbuildSelect(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState, jakarta.persistence.criteria.Selection<?> selection, boolean distinct) Build select statement.buildUpdate(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryBuilder2.UpdateQueryDefinition definition) Encode the given query into the encoded query instance.protected voidbuildWhereClause(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, jakarta.persistence.criteria.Predicate predicate, AbstractSqlLikeQueryBuilder2.QueryState queryState) Builds where clause.protected voidIf and whenEntityRepresentationannotation with JSON type is used for the repository method but dialect does not support JSON entity representations this will throwIllegalArgumentException.protected abstract booleanWhether property path expressions require computation by the implementation.createPredicateVisitor(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState) Create a predicate visitor.createSelectionVisitor(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState, boolean distinct) Create a selection visitor.protected abstract AbstractSqlLikeQueryBuilder2.PlaceholderformatParameter(int index) Format the parameter at the given index.protected StringgetAliasName(PersistentEntity entity) Get an alias name for the given entity.getAliasName(JoinPath joinPath) Get the alias name.protected final StringgetColumnAlias(PersistentProperty property) Gets column alias if defined as alias field on MappedProperty annotation on the mapping field.protected abstract StringgetColumnName(PersistentProperty persistentProperty) Get the column name for the given property.getDataTransformerReadValue(String alias, PersistentProperty prop) Returns transformed value if the data transformer id defined.getDataTransformerWriteValue(String alias, PersistentProperty prop) Returns transformed value if the data transformer id defined.protected DialectGet dialect.protected @NonNull StringgetMappedName(@NonNull NamingStrategy namingStrategy, @NonNull Association association) Gets the mapped name from the association usingNamingStrategy.protected @NonNull StringgetMappedName(@NonNull NamingStrategy namingStrategy, @NonNull PersistentPropertyPath propertyPath) Gets the mapped name from for the list of associations and property usingNamingStrategy.protected @NonNull StringgetMappedName(@NonNull NamingStrategy namingStrategy, @NonNull List<Association> associations, @NonNull PersistentProperty property) Gets the mapped name from for the list of associations and property usingNamingStrategy.protected NamingStrategygetNamingStrategy(PersistentEntity entity) GetsNamingStrategyfor the entity.protected NamingStrategygetNamingStrategy(PersistentPropertyPath propertyPath) GetsNamingStrategyfor the property path.protected @NonNull StringgetPathOnlyAliasName(JoinPath joinPath) Get the alias name for just the join path.protected StringGet the AS keyword to use for table aliases.protected abstract StringgetTableName(PersistentEntity entity) Get the table name for the given entity.protected StringGet the table name for the given entity.protected abstract booleanisAliasForBatch(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Should aliases be used in batch statements.protected booleanisJsonEntity(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, PersistentEntity entity) Checks whetherEntityRepresentationannotation with JSON type is used for the repository method.protected BindingParameter.BindingContextnewBindingContext(@Nullable PersistentPropertyPath ref) Creates new binding parameter context.protected static booleanparameterInRoleModifiesLimit(Map<Integer, String> parametersInRole) protected static booleanparameterInRoleModifiesOrder(Map<Integer, String> parametersInRole) protected StringQuote a column name for the dialect.protected StringQuote a persisted name (schema, table or column name) for the dialect.abstract StringResolves the join type.protected final StringresolveWhereForAnnotationMetadata(String alias, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Resolves where clause if there isWhereannotation on the entity.protected booleanshouldAppendOrder(QueryBuilder2.SelectQueryDefinition definition) Should append order.protected booleanshouldEscape(@NonNull PersistentEntity entity) Whether queries should be escaped for the given entity.protected booleanprotected booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.data.model.query.builder.QueryBuilder2
buildInsert
-
Field Details
-
ORDER_BY_CLAUSE
- See Also:
-
SELECT_CLAUSE
- See Also:
-
AS_CLAUSE
- See Also:
-
FROM_CLAUSE
- See Also:
-
WHERE_CLAUSE
- See Also:
-
COMMA
protected static final char COMMA- See Also:
-
CLOSE_BRACKET
protected static final char CLOSE_BRACKET- See Also:
-
OPEN_BRACKET
protected static final char OPEN_BRACKET- See Also:
-
SPACE
protected static final char SPACE- See Also:
-
DOT
protected static final char DOT- See Also:
-
NOT
- See Also:
-
AND
- See Also:
-
LOGICAL_AND
- See Also:
-
RETURNING
- See Also:
-
OR
- See Also:
-
LOGICAL_OR
- See Also:
-
DISTINCT
- See Also:
-
ALIAS_REPLACE_QUOTED
- See Also:
-
CANNOT_QUERY_ON_ID_WITH_ENTITY_THAT_HAS_NO_ID
- See Also:
-
-
Constructor Details
-
AbstractSqlLikeQueryBuilder2
public AbstractSqlLikeQueryBuilder2()
-
-
Method Details
-
getDialect
Get dialect.- Returns:
- dialect
-
traverseEmbedded
protected boolean traverseEmbedded()- Returns:
- True if embedded properties should be traversed
-
asLiteral
Convert the literal value to it's SQL representation.- Parameters:
value- The literal value- Returns:
- converter value
-
asQueryPropertyPath
protected final AbstractSqlLikeQueryBuilder2.QueryPropertyPath asQueryPropertyPath(String tableAlias, PersistentProperty persistentProperty) -
buildSelect
public QueryResult buildSelect(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.SelectQueryDefinition definition) Description copied from interface:QueryBuilder2Encode the given query for the passed annotation metadata and query.- Specified by:
buildSelectin interfaceQueryBuilder2- Parameters:
annotationMetadata- The annotation metadatadefinition- The query model- Returns:
- The query result
-
shouldAppendOrder
Should append order.- Parameters:
definition- The definition- Returns:
- true if should
-
parameterInRoleModifiesOrder
-
parameterInRoleModifiesLimit
-
buildQuery
@NonNull protected final @NonNull AbstractSqlLikeQueryBuilder2.QueryState buildQuery(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.SelectQueryDefinition definition, AbstractSqlLikeQueryBuilder2.QueryBuilder queryBuilder, boolean appendLimit, boolean appendOrder, @Nullable @Nullable String tableAliasPrefix) -
supportsLimitQuery
protected boolean supportsLimitQuery()- Returns:
- True if limit is supported in the query
-
appendLimitAndOrder
protected void appendLimitAndOrder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.SelectQueryDefinition definition, boolean appendLimit, boolean appendOrder, AbstractSqlLikeQueryBuilder2.QueryState queryState) -
getTableName
Get the table name for the given entity.- Parameters:
entity- The entity- Returns:
- The table name
-
getUnescapedTableName
Get the table name for the given entity.- Parameters:
entity- The entity- Returns:
- The table name
-
getAliasName
Get an alias name for the given entity.- Parameters:
entity- The entity- Returns:
- The alias name
-
getAliasName
Get the alias name.- Parameters:
joinPath- The join path- Returns:
- The alias
-
getPathOnlyAliasName
Get the alias name for just the join path.- Parameters:
joinPath- The join path- Returns:
- The alias
-
buildJoin
protected void buildJoin(String joinType, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, PersistentAssociationPath joinAssociation, PersistentEntity associationOwner, String currentJoinAlias, String lastJoinAlias) Build a join expression for the given alias, association, join type and builder.- Parameters:
joinType- The join typequery- The query builderqueryState- The statejoinAssociation- The associationassociationOwner- The associated ownercurrentJoinAlias- The current join aliaslastJoinAlias- The last join alias
-
getColumnName
Get the column name for the given property.- Parameters:
persistentProperty- The property- Returns:
- The column name
-
shouldEscape
Whether queries should be escaped for the given entity.- Parameters:
entity- The entity- Returns:
- True if they should be escaped
-
getTableAsKeyword
Get the AS keyword to use for table aliases.- Returns:
- The AS keyword if any
-
quote
Quote a column name for the dialect.- Parameters:
persistedName- The persisted name.- Returns:
- The quoted name
-
quote
Quote a persisted name (schema, table or column name) for the dialect.- Parameters:
persistedName- The persisted name.supportsDynamicValues- Whether persisted name supports dynamic values. Schema and table can have dynamic value (like ${config.entry}) and columns can't.- Returns:
- The quoted name
-
buildSelect
protected void buildSelect(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState, jakarta.persistence.criteria.Selection<?> selection, boolean distinct) Build select statement.- Parameters:
annotationMetadata- the annotation metadataqueryState- the query stateselection- projection list (can be empty, then selects all columns)distinct- is distinct selection
-
createSelectionVisitor
protected AbstractSqlLikeQueryBuilder2.SqlSelectionVisitor createSelectionVisitor(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState, boolean distinct) Create a selection visitor.- Parameters:
annotationMetadata- The annotation metadataqueryState- The query statedistinct- The distinct- Returns:
- The visitor
-
getNamingStrategy
GetsNamingStrategyfor the property path. Subclasses might override and potentially provide different strategy in some cases.- Parameters:
propertyPath- the property path representation- Returns:
- naming strategy for the property path
-
getNamingStrategy
GetsNamingStrategyfor the entity. Subclasses might override and potentially provide different strategy in some cases.- Parameters:
entity- the persistent entity- Returns:
- naming strategy for the entity
-
getMappedName
@NonNull protected @NonNull String getMappedName(@NonNull @NonNull NamingStrategy namingStrategy, @NonNull @NonNull Association association) Gets the mapped name from the association usingNamingStrategy.- Parameters:
namingStrategy- the naming strategy being usedassociation- the association- Returns:
- the mapped name for the association
-
getMappedName
@NonNull protected @NonNull String getMappedName(@NonNull @NonNull NamingStrategy namingStrategy, @NonNull @NonNull List<Association> associations, @NonNull @NonNull PersistentProperty property) Gets the mapped name from for the list of associations and property usingNamingStrategy.- Parameters:
namingStrategy- the naming strategyassociations- the association listproperty- the property- Returns:
- the mappen name for the list of associations and property using given naming strategy
-
getMappedName
@NonNull protected @NonNull String getMappedName(@NonNull @NonNull NamingStrategy namingStrategy, @NonNull @NonNull PersistentPropertyPath propertyPath) Gets the mapped name from for the list of associations and property usingNamingStrategy.- Parameters:
namingStrategy- the naming strategypropertyPath- the property path- Returns:
- the mappen name for the list of associations and property using given naming strategy
-
buildWhereClause
protected void buildWhereClause(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, jakarta.persistence.criteria.Predicate predicate, AbstractSqlLikeQueryBuilder2.QueryState queryState) Builds where clause.- Parameters:
annotationMetadata- the annotation metadata for the methodpredicate- the predicatequeryState- the query state
-
createPredicateVisitor
protected AbstractSqlLikeQueryBuilder2.SqlPredicateVisitor createPredicateVisitor(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState) Create a predicate visitor.- Parameters:
annotationMetadata- The annotation metadataqueryState- The query state- Returns:
- The visitor
-
buildAdditionalWhereClause
protected String buildAdditionalWhereClause(AbstractSqlLikeQueryBuilder2.QueryState queryState, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds additional where clause if there isWhereannotation on the entity.- Parameters:
queryState- the query stateannotationMetadata- the annotation metadata- Returns:
- where clause if there was
Whereannotation on the entity (or joins for JPA implementation)
-
buildAdditionalWhereString
protected String buildAdditionalWhereString(String alias, PersistentEntity entity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds WHERE clause for the entity and given alias ifIgnoreWhereis not present.- Parameters:
alias- the entity aliasentity- the entityannotationMetadata- the entity metadata- Returns:
- the WHERE clause
-
buildAdditionalWhereString
protected final String buildAdditionalWhereString(JoinPath joinPath, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Builds WHERE clause based onWhereannotation on the metadata.- Parameters:
joinPath- the join pathannotationMetadata- the annotation metadata- Returns:
- WHERE clause if
Whereannotation is declared andIgnoreWhereis not present, otherwise empty string
-
resolveWhereForAnnotationMetadata
protected final String resolveWhereForAnnotationMetadata(String alias, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Resolves where clause if there isWhereannotation on the entity.- Parameters:
alias- the entity aliasannotationMetadata- the entity annotation metadata- Returns:
- where clause with entity alias if entity has declared where annotation
-
appendOrder
protected void appendOrder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, List<jakarta.persistence.criteria.Order> orders, AbstractSqlLikeQueryBuilder2.QueryState queryState) Appends order to the query.- Parameters:
annotationMetadata- the annotation metadataorders- the ordersqueryState- the query state
-
appendForUpdate
protected void appendForUpdate(AbstractSqlLikeQueryBuilder2.QueryPosition queryPosition, QueryBuilder2.SelectQueryDefinition definition, StringBuilder queryBuilder) Adds "forUpdate" pessimistic locking.- Parameters:
queryPosition- The query positiondefinition- The definitionqueryBuilder- The builder
-
appendUpdateSetParameter
protected void appendUpdateSetParameter(StringBuilder sb, String alias, PersistentProperty prop, Runnable appendParameter) Appends the SET=? call to the query string.- Parameters:
sb- The string builderalias- The aliasprop- The propertyappendParameter- The append parameter action
-
appendTransformed
Appends custom query part.- Parameters:
sb- The string buildertransformed- The transformed query partappendParameter- The append parameter action
-
computePropertyPaths
protected abstract boolean computePropertyPaths()Whether 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.- Returns:
- True if property path computation is required.
-
buildUpdate
public QueryResult buildUpdate(@NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryBuilder2.UpdateQueryDefinition definition) Description copied from interface:QueryBuilder2Encode the given query into the encoded query instance.- Specified by:
buildUpdatein interfaceQueryBuilder2- Parameters:
annotationMetadata- The annotation metadatadefinition- The definition- Returns:
- The encoded query
-
buildDelete
public QueryResult buildDelete(@NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryBuilder2.DeleteQueryDefinition definition) Description copied from interface:QueryBuilder2Encode the given query into the encoded query instance.- Specified by:
buildDeletein interfaceQueryBuilder2- Parameters:
annotationMetadata- The annotation metadatadefinition- The query definition- Returns:
- The encoded query
-
isAliasForBatch
protected abstract boolean isAliasForBatch(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Should aliases be used in batch statements.- Parameters:
persistentEntity- the persistent entityannotationMetadata- the method annotation metadata- Returns:
- True if they should
-
appendDeleteClause
Append the delete clause.- Parameters:
queryString- The query string- Returns:
- The delete clause
-
buildOrderBy
@NonNull public @NonNull String buildOrderBy(String query, @NonNull @NonNull PersistentEntity entity, @NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull Sort sort, boolean nativeQuery, @Nullable @Nullable String tableAlias) Encode the given query into the encoded query instance.- Parameters:
query- The queryentity- The root entityannotationMetadata- The annotation metadatasort- The sortnativeQuery- Whether the query is native query, in which case sort field names will be supplied by the user and not verifiedtableAlias- The table alias- Returns:
- The encoded query
-
buildPropertyByName
public String buildPropertyByName(@NonNull @NonNull String propertyName, @NonNull @NonNull String query, @NonNull @NonNull PersistentEntity entity, @NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, boolean nativeQuery, @Nullable @Nullable String tableAlias) Encode the given property retrieval into a query instance. For example, property name might be encoded as`person_.name`using its path and table's alias.- Parameters:
propertyName- The name of the propertyquery- The queryentity- The root entityannotationMetadata- The annotation metadatanativeQuery- Whether the query is native query, in which case the property name will be supplied by the user and not verifiedtableAlias- The table alias- Returns:
- The encoded query
-
asPath
Join associations and property as path.- Parameters:
associations- The associationsproperty- The property- Returns:
- joined path
-
newBindingContext
protected BindingParameter.BindingContext newBindingContext(@Nullable @Nullable PersistentPropertyPath ref) Creates new binding parameter context.- Parameters:
ref- the persistent property reference- Returns:
- new binding parameter context
-
getDataTransformerReadValue
Returns transformed value if the data transformer id defined.- Parameters:
alias- query table aliasprop- a property- Returns:
- optional transformed value
-
getDataTransformerWriteValue
Returns transformed value if the data transformer id defined.- Parameters:
alias- query table aliasprop- a property- Returns:
- optional transformed value
-
formatParameter
Format the parameter at the given index.- Parameters:
index- The parameter- Returns:
- The index
-
resolveJoinType
Resolves the join type.- Parameters:
jt- The join type- Returns:
- The join type.
-
getColumnAlias
Gets column alias if defined as alias field on MappedProperty annotation on the mapping field.- Parameters:
property- the persistent property- Returns:
- column alias if defined, otherwise an empty string
-
checkDialectSupportsJsonEntity
If and whenEntityRepresentationannotation with JSON type is used for the repository method but dialect does not support JSON entity representations this will throwIllegalArgumentException.- Parameters:
entity- the persistent entity
-
isJsonEntity
protected boolean isJsonEntity(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, PersistentEntity entity) Checks whetherEntityRepresentationannotation with JSON type is used for the repository method. If current dialect does not support handling JSON entity representations,IllegalArgumentExceptionis thrown.- Parameters:
annotationMetadata- the annotation metadataentity- the persistent entity- Returns:
- true if
EntityRepresentationannotation with JSON type is used for the repository method
-
appendExpression
protected final void appendExpression(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, jakarta.persistence.criteria.Expression<?> expression, boolean isProjection) -
appendPropertyRef
protected final void appendPropertyRef(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, PersistentPropertyPath pp, boolean isProjection) -
buildLimitAndOffset
Description copied from interface:QueryBuilder2Generate the limit and offset query.- Specified by:
buildLimitAndOffsetin interfaceQueryBuilder2- Parameters:
limit- The limit (-1 of not set)offset- The offset (0 if not set)- Returns:
- The encoded query
-
appendLimitAndOffset
protected void appendLimitAndOffset(Dialect dialect, long limit, long offset, StringBuilder builder) Append limit and offset.- Parameters:
dialect- The dialectlimit- The limitoffset- The offsetbuilder- The builder
-