Class QueryCompilation
- java.lang.Object
-
- org.datanucleus.store.query.compiler.QueryCompilation
-
- All Implemented Interfaces:
Serializable
public class QueryCompilation extends Object implements Serializable
Representation of the components of a compiled java "string-based" query. Assumes that the query has the following formsSELECT {result} FROM {from} WHERE {filter} GROUP BY {grouping} HAVING {having} ORDER BY {order} UPDATE {from} SET {update} WHERE {filter} DELETE FROM {from} WHERE {filter}
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
candidateAlias
Alias for the (primary) candidate.protected Class
candidateClass
Primary candidate class.protected Expression
exprFilter
Compiled filter expressionprotected Expression[]
exprFrom
Compiled from expression.protected Expression[]
exprGrouping
Compiled grouping expression.protected Expression
exprHaving
Compiled having expression.protected Expression[]
exprOrdering
Compiled ordering expression.protected Expression[]
exprResult
Compiled result expression.protected Expression[]
exprUpdate
Compiled update expression.protected String
queryLanguage
Query language that this is a compilation for.protected boolean
resultDistinct
Whether the result is distinct.protected boolean
returnsSingleRow
Whether the query will return a single row.protected Map<String,QueryCompilation>
subqueryCompilations
Compilations of any subqueries, keyed by the subquery variable name.protected SymbolTable
symtbl
Compiled Symbol Table.
-
Constructor Summary
Constructors Constructor Description QueryCompilation(Class candidateCls, String candidateAlias, SymbolTable symtbl, Expression[] results, Expression[] froms, Expression filter, Expression[] groupings, Expression having, Expression[] orderings, Expression[] updates)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubqueryCompilation(String alias, QueryCompilation compilation)
Method to add the compilation for a subquery of this query.String
debugString(String indent)
String
getCandidateAlias()
Accessor for the candidate alias.Class
getCandidateClass()
Accessor for the candidate class.QueryCompilation
getCompilationForSubquery(String alias)
Accessor for the compilation for a subquery with the specified alias.Expression
getExprFilter()
Accessor for the filter expression.Expression[]
getExprFrom()
Accessor for any from expression(s).Expression[]
getExprGrouping()
Accessor for any grouping expression(s).Expression
getExprHaving()
Accessor for any having expression.Expression[]
getExprOrdering()
Accessor for any ordering expression(s).Expression[]
getExprResult()
Accessor for any result expression(s).Expression[]
getExprUpdate()
Accessor for any update expression(s).ParameterExpression
getParameterExpressionForPosition(int pos)
String
getQueryLanguage()
boolean
getResultDistinct()
Class[]
getResultTypes()
Accessor for the types of the result row components.String[]
getSubqueryAliases()
Accessor for the aliases for any subqueries in this compilation.SymbolTable
getSymbolTable()
Accessor for the symbol table for the query.boolean
returnsSingleRow()
Accessor for whether this query will return a single row.void
setExprFilter(Expression filter)
void
setExprHaving(Expression having)
void
setQueryLanguage(String lang)
void
setResultDistinct()
void
setReturnsSingleRow()
String
toString()
-
-
-
Field Detail
-
queryLanguage
protected String queryLanguage
Query language that this is a compilation for.
-
candidateClass
protected Class candidateClass
Primary candidate class.
-
candidateAlias
protected String candidateAlias
Alias for the (primary) candidate. Defaults to "this".
-
returnsSingleRow
protected boolean returnsSingleRow
Whether the query will return a single row.
-
symtbl
protected SymbolTable symtbl
Compiled Symbol Table.
-
resultDistinct
protected boolean resultDistinct
Whether the result is distinct.
-
exprResult
protected Expression[] exprResult
Compiled result expression.
-
exprFrom
protected Expression[] exprFrom
Compiled from expression.
-
exprUpdate
protected Expression[] exprUpdate
Compiled update expression.
-
exprFilter
protected Expression exprFilter
Compiled filter expression
-
exprGrouping
protected Expression[] exprGrouping
Compiled grouping expression.
-
exprHaving
protected Expression exprHaving
Compiled having expression.
-
exprOrdering
protected Expression[] exprOrdering
Compiled ordering expression.
-
subqueryCompilations
protected Map<String,QueryCompilation> subqueryCompilations
Compilations of any subqueries, keyed by the subquery variable name.
-
-
Constructor Detail
-
QueryCompilation
public QueryCompilation(Class candidateCls, String candidateAlias, SymbolTable symtbl, Expression[] results, Expression[] froms, Expression filter, Expression[] groupings, Expression having, Expression[] orderings, Expression[] updates)
-
-
Method Detail
-
setQueryLanguage
public void setQueryLanguage(String lang)
-
getQueryLanguage
public String getQueryLanguage()
-
setResultDistinct
public void setResultDistinct()
-
getResultDistinct
public boolean getResultDistinct()
-
setReturnsSingleRow
public void setReturnsSingleRow()
-
addSubqueryCompilation
public void addSubqueryCompilation(String alias, QueryCompilation compilation)
Method to add the compilation for a subquery of this query.- Parameters:
alias
- Alias for the subquery (variable name)compilation
- The compilation
-
getCompilationForSubquery
public QueryCompilation getCompilationForSubquery(String alias)
Accessor for the compilation for a subquery with the specified alias.- Parameters:
alias
- Alias of subquery- Returns:
- The compilation
-
getSubqueryAliases
public String[] getSubqueryAliases()
Accessor for the aliases for any subqueries in this compilation.- Returns:
- The subquery aliases (if any)
-
returnsSingleRow
public boolean returnsSingleRow()
Accessor for whether this query will return a single row. This is true if all result selects are aggregates, or the user has set "unique" on the query.- Returns:
- Whether this query will return a single row
-
getResultTypes
public Class[] getResultTypes()
Accessor for the types of the result row components. If no result is defined then will be an array of size 1 with element type "candidate".- Returns:
- The result type(s)
-
getCandidateClass
public Class getCandidateClass()
Accessor for the candidate class.- Returns:
- Candidate class
-
getCandidateAlias
public String getCandidateAlias()
Accessor for the candidate alias.- Returns:
- Candidate alias
-
getSymbolTable
public SymbolTable getSymbolTable()
Accessor for the symbol table for the query.- Returns:
- Symbol table, for parameter, variable lookup.
-
getExprResult
public Expression[] getExprResult()
Accessor for any result expression(s).- Returns:
- The results
-
getExprFrom
public Expression[] getExprFrom()
Accessor for any from expression(s).- Returns:
- The from clauses
-
getExprUpdate
public Expression[] getExprUpdate()
Accessor for any update expression(s).- Returns:
- The updates
-
getExprFilter
public Expression getExprFilter()
Accessor for the filter expression.- Returns:
- The filter
-
setExprFilter
public void setExprFilter(Expression filter)
-
getExprGrouping
public Expression[] getExprGrouping()
Accessor for any grouping expression(s).- Returns:
- The grouping
-
getExprHaving
public Expression getExprHaving()
Accessor for any having expression.- Returns:
- The having clause
-
setExprHaving
public void setExprHaving(Expression having)
-
getExprOrdering
public Expression[] getExprOrdering()
Accessor for any ordering expression(s).- Returns:
- The ordering
-
getParameterExpressionForPosition
public ParameterExpression getParameterExpressionForPosition(int pos)
-
-