Class JDOQLCompiler
- java.lang.Object
-
- org.datanucleus.store.query.compiler.JavaQueryCompiler
-
- org.datanucleus.store.query.compiler.JDOQLCompiler
-
- All Implemented Interfaces:
SymbolResolver
public class JDOQLCompiler extends JavaQueryCompiler
Implementation of a compiler for JDOQL (JSR0012, JSR0243).
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
allowAll
-
Fields inherited from class org.datanucleus.store.query.compiler.JavaQueryCompiler
candidateAlias, candidateAliasOrig, candidateClass, candidates, caseSensitiveAliases, clr, filter, from, grouping, having, imports, JOIN_INNER, JOIN_INNER_FETCH, JOIN_OUTER, JOIN_OUTER_FETCH, JOIN_OUTER_FETCH_RIGHT, JOIN_OUTER_RIGHT, metaDataManager, options, ordering, parameters, parameterSubstitutionNumber, parameterSubtitutionMap, parentCompiler, parser, queryMgr, result, symtbl, update, variables
-
-
Constructor Summary
Constructors Constructor Description JDOQLCompiler(PersistenceNucleusContext nucCtx, ClassLoaderResolver clr, java.lang.String from, java.lang.Class candidateClass, java.util.Collection candidates, java.lang.String filter, Imports imports, java.lang.String ordering, java.lang.String result, java.lang.String grouping, java.lang.String having, java.lang.String params, java.lang.String variables, java.lang.String update)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
caseSensitiveSymbolNames()
Whether names of symbols are case-sensitive (e.g JDOQL returns true, but JPQL returns false).QueryCompilation
compile(java.util.Map parameters, java.util.Map<java.lang.String,java.lang.Object> subqueryMap)
Method to compile the query, and return the compiled results.Expression[]
compileUpdate()
private static boolean
containsOnlyGroupingOrAggregates(Expression expr, Expression[] exprGrouping)
Convenience method to check the provided expression for whether it contains only grouping expressions or aggregatesjava.lang.String
getLanguage()
Accessor for the query language name.private static boolean
isExpressionGroupingOrAggregate(Expression expr, Expression[] exprGrouping)
Convenience method to check of the provided expression is either an aggregate expression or is a grouping expression (or literal, parameter, or variable).protected boolean
isKeyword(java.lang.String name)
Method to return if the supplied name is a keyword.private static boolean
isMethodNameAggregate(java.lang.String methodName)
void
setAllowAll(boolean allow)
Mutator for whether we should allow all JDOQL syntax (as opposed to strict JDOQL from the spec).boolean
supportsImplicitVariables()
Whether we should accept implicit variables in the query.-
Methods inherited from class org.datanucleus.store.query.compiler.JavaQueryCompiler
compileCandidatesParametersVariables, compileFilter, compileFrom, compileGrouping, compileHaving, compileOrdering, compileResult, getPrimaryClass, getType, getType, resolveClass, setLinkToParentQuery, setOption, swapCandidateAliasNodeName, swapSubqueryParameters
-
-
-
-
Constructor Detail
-
JDOQLCompiler
public JDOQLCompiler(PersistenceNucleusContext nucCtx, ClassLoaderResolver clr, java.lang.String from, java.lang.Class candidateClass, java.util.Collection candidates, java.lang.String filter, Imports imports, java.lang.String ordering, java.lang.String result, java.lang.String grouping, java.lang.String having, java.lang.String params, java.lang.String variables, java.lang.String update)
-
-
Method Detail
-
setAllowAll
public void setAllowAll(boolean allow)
Mutator for whether we should allow all JDOQL syntax (as opposed to strict JDOQL from the spec).- Parameters:
allow
- Whether to allow
-
compile
public QueryCompilation compile(java.util.Map parameters, java.util.Map<java.lang.String,java.lang.Object> subqueryMap)
Method to compile the query, and return the compiled results.- Specified by:
compile
in classJavaQueryCompiler
- Parameters:
parameters
- the parameter map of values keyed by param namesubqueryMap
- Map of subquery variables, keyed by the subquery name- Returns:
- The compiled query
-
compileUpdate
public Expression[] compileUpdate()
- Overrides:
compileUpdate
in classJavaQueryCompiler
-
containsOnlyGroupingOrAggregates
private static boolean containsOnlyGroupingOrAggregates(Expression expr, Expression[] exprGrouping)
Convenience method to check the provided expression for whether it contains only grouping expressions or aggregates- Parameters:
expr
- The expression to checkexprGrouping
- The grouping expressions- Returns:
- Whether it contains only grouping or aggregates
-
isMethodNameAggregate
private static boolean isMethodNameAggregate(java.lang.String methodName)
-
isExpressionGroupingOrAggregate
private static boolean isExpressionGroupingOrAggregate(Expression expr, Expression[] exprGrouping)
Convenience method to check of the provided expression is either an aggregate expression or is a grouping expression (or literal, parameter, or variable).- Parameters:
expr
- The expression to checkexprGrouping
- The grouping expressions- Returns:
- Whether it passes the test
-
supportsImplicitVariables
public boolean supportsImplicitVariables()
Description copied from interface:SymbolResolver
Whether we should accept implicit variables in the query. JDOQL supports variables, yet JPQL doesn't. Also in JDOQL if the user supplies some explicit variables then it doesn't allow implicit variables.- Returns:
- Whether to support implicit variables
-
caseSensitiveSymbolNames
public boolean caseSensitiveSymbolNames()
Description copied from interface:SymbolResolver
Whether names of symbols are case-sensitive (e.g JDOQL returns true, but JPQL returns false).- Returns:
- Whether case sensitive
-
getLanguage
public java.lang.String getLanguage()
Accessor for the query language name.- Specified by:
getLanguage
in classJavaQueryCompiler
- Returns:
- Name of the query language.
-
isKeyword
protected boolean isKeyword(java.lang.String name)
Method to return if the supplied name is a keyword. Keywords can only appear at particular places in a query so we need to detect for valid queries.- Specified by:
isKeyword
in classJavaQueryCompiler
- Parameters:
name
- The name- Returns:
- Whether it is a keyword
-
-