public interface JPQLResolutionContext extends JpaContext, com.holonplatform.core.ExpressionResolver.ResolutionContext, com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport
ExpressionResolver.ResolutionContext.
Supports ExpressionResolvers to resolve JPQL expressions.
Supports named parameters definitions, which can be added using addNamedParameter(JPQLParameter). The named
parameters can provided to a query definition using setupQueryParameters(Query).
JPQL compostion contexts are hierarchical and provides methods to get the parent context and to create children using
childContext().
| Modifier and Type | Interface and Description |
|---|---|
static class |
JPQLResolutionContext.JPQLStatementPreparationException
Runtime exception related to JPQL statements preparation errors.
|
| Modifier and Type | Method and Description |
|---|---|
default <T> String |
addNamedParameter(JPQLParameter<T> parameter)
Convenience method to add a named parameter using current
JPQLContextParametersHandler. |
JPQLResolutionContext |
childContext()
Create a new
JPQLResolutionContext as child of this context. |
static JPQLResolutionContext |
create(JpaContext context)
Create a new default
JPQLResolutionContext. |
static int |
getContextSequence(JPQLResolutionContext context,
Class<? extends JPQLResolutionContext> contextType)
Get the given
context hierarchy sequence, where 0 is the sequence number of the root
context. |
JPQLContextParametersHandler |
getNamedParametersHandler()
Get the JPQL named parameters handler.
|
Optional<JPQLResolutionContext> |
getParent()
Get the parent context, if available.
|
static Optional<JPQLResolutionContext> |
isJPQLResolutionContext(com.holonplatform.core.ExpressionResolver.ResolutionContext context)
Checks if given
ExpressionResolver.ResolutionContext is a JPQLResolutionContext. |
default Optional<JPQLStatementResolutionContext> |
isStatementCompositionContext()
Checks whether this context is a
JPQLStatementResolutionContext. |
default <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> |
resolve(E expression,
Class<R> resolutionType)
Try to resolve given
expression using current context resolvers to obtain a
resolutionType type expression. |
default <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> |
resolveOrFail(E expression,
Class<R> resolutionType)
Resolve given
expression using current context resolvers to obtain a resolutionType
type expression. |
void |
setupQueryParameters(javax.persistence.Query query)
Setup given
query parameters using the named parameters defined in this context. |
getDialect, getEntityManagerFactory, getORMPlatform, getValueDeserializer, getValueSerializer, trace, traceOperationresolveOptional<JPQLResolutionContext> getParent()
JPQLContextParametersHandler getNamedParametersHandler()
default <T> String addNamedParameter(JPQLParameter<T> parameter)
JPQLContextParametersHandler.T - Parameter expression typeparameter - Parameter definition (not null)void setupQueryParameters(javax.persistence.Query query)
query parameters using the named parameters defined in this context.query - The JPQL query to configure (not null)JPQLResolutionContext.JPQLStatementPreparationException - If an error occurreddefault <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> Optional<R> resolve(E expression, Class<R> resolutionType) throws com.holonplatform.core.Expression.InvalidExpressionException
expression using current context resolvers to obtain a
resolutionType type expression.
The resolved expression is validate using Expression.validate() before returning it to caller.
E - Expression typeR - Resolution typeexpression - Expression to resolveresolutionType - Expression type to obtaincom.holonplatform.core.Expression.InvalidExpressionExceptiondefault <E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression> R resolveOrFail(E expression,
Class<R> resolutionType)
expression using current context resolvers to obtain a resolutionType
type expression. If no ExpressionResolver is available to resolve given expression, an
Expression.InvalidExpressionException is thrown.
The resolved expression is validate using Expression.validate() before returning it to caller.
E - Expression typeR - Resolution typeexpression - Expression to resolveresolutionType - Expression type to obtaincom.holonplatform.core.Expression.InvalidExpressionException - If an error occurred during resolution, or if no ExpressionResolver is
available to resolve given expression or if expression validation failedJPQLResolutionContext childContext()
JPQLResolutionContext as child of this context. This context will be setted as parent of the
new context.JPQLResolutionContext with this context as parentdefault Optional<JPQLStatementResolutionContext> isStatementCompositionContext()
JPQLStatementResolutionContext.JPQLStatementResolutionContext returns the context itself as
JPQLStatementResolutionContext, otherwise returns an empty Optionalstatic JPQLResolutionContext create(JpaContext context)
JPQLResolutionContext.context - JPA context to use (not null)JPQLResolutionContextstatic Optional<JPQLResolutionContext> isJPQLResolutionContext(com.holonplatform.core.ExpressionResolver.ResolutionContext context)
ExpressionResolver.ResolutionContext is a JPQLResolutionContext.context - The context to checkJPQLResolutionContext, it is returned as a JPQLResolutionContext
type. Otherwise, an empty Optional is returned.static int getContextSequence(JPQLResolutionContext context, Class<? extends JPQLResolutionContext> contextType)
context hierarchy sequence, where 0 is the sequence number of the root
context.context - The context for which to obtain the sequence (not null)contextType - The context type to take into account to calculate the sequenceCopyright © 2019 The Holon Platform. All rights reserved.