Interface QueryGenerator
- All Known Implementing Classes:
QueryToSQLMapper
public interface QueryGenerator
Interface for a generator of query statements.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bindParameter
(String paramName, Class type) Method to bind the specified parameter to the defined type.void
bindVariable
(String varName, org.datanucleus.metadata.AbstractClassMetaData cmd, SQLTable sqlTbl, JavaTypeMapping mapping) Method to bind the specified variable to the table and mapping.bindVariable
(UnboundExpression expr, Class type) Method to bind the specified unbound variable (as cross join).org.datanucleus.ClassLoaderResolver
Accessor for the ClassLoader resolver to use when looking up classes.org.datanucleus.store.query.compiler.CompilationComponent
Accessor for the current query component being compiled.org.datanucleus.ExecutionContext
Accessor for the ExecutionContext for this query.getProperty
(String name) Accessor for a property affecting the query compilation.Accessor for the query language that this query pertains to.getTypeOfVariable
(String varName) Accessor for the type of a variable if already known (declared?).Accessor for the value of the specified query extension (or null if not defined).boolean
Accessor for whether the query has explicit joins.boolean
hasExtension
(String key) Accessor for whether the query being generated has the specified extension.boolean
resolveClass
(String className) Convenience method to resolve a class name.void
useParameterExpressionAsLiteral
(SQLLiteral paramLiteral) Method to instruct the generator to convert the provided parameter expression to just be a literal using the value of the parameter (hence the statement cannot be precompilable since the value needs to be known).
-
Method Details
-
getQueryLanguage
String getQueryLanguage()Accessor for the query language that this query pertains to. Can be used to decide how to handle the input.- Returns:
- The query language
-
getClassLoaderResolver
org.datanucleus.ClassLoaderResolver getClassLoaderResolver()Accessor for the ClassLoader resolver to use when looking up classes.- Returns:
- The classloader resolver
-
getExecutionContext
org.datanucleus.ExecutionContext getExecutionContext()Accessor for the ExecutionContext for this query.- Returns:
- ExecutionContext
-
getCompilationComponent
org.datanucleus.store.query.compiler.CompilationComponent getCompilationComponent()Accessor for the current query component being compiled.- Returns:
- Component being compiled (if any)
-
getProperty
Accessor for a property affecting the query compilation. This can be something like whether there is an OR in the filter, which can then impact on the type of SQL used.- Parameters:
name
- The property name- Returns:
- Its value
-
useParameterExpressionAsLiteral
Method to instruct the generator to convert the provided parameter expression to just be a literal using the value of the parameter (hence the statement cannot be precompilable since the value needs to be known).- Parameters:
paramLiteral
- The parameter expression
-
getTypeOfVariable
Accessor for the type of a variable if already known (declared?).- Parameters:
varName
- Name of the variable- Returns:
- The type if it is known
-
bindVariable
void bindVariable(String varName, org.datanucleus.metadata.AbstractClassMetaData cmd, SQLTable sqlTbl, JavaTypeMapping mapping) Method to bind the specified variable to the table and mapping.- Parameters:
varName
- Variable namecmd
- Metadata for this variable typesqlTbl
- Table for this variablemapping
- The mapping of this variable in the table
-
bindVariable
Method to bind the specified unbound variable (as cross join).- Parameters:
expr
- Unbound expressiontype
- The type to bind as- Returns:
- The bound expression to use instead
-
hasExplicitJoins
boolean hasExplicitJoins()Accessor for whether the query has explicit joins. A JPQL query has explicit joins, whereas a JDOQL query has variables and hence implicit joins. If not then has implicit joins, meaning that they could potentially be rebound later if prematurely bound in a particular way.- Returns:
- Whether the query has explicit joins
-
processingOnClause
boolean processingOnClause() -
bindParameter
Method to bind the specified parameter to the defined type. If the parameter is already bound (declared in the query perhaps, or bound via an earlier usage) then does nothing.- Parameters:
paramName
- Name of the parametertype
- The type (or subclass)
-
resolveClass
Convenience method to resolve a class name.- Parameters:
className
- The class name- Returns:
- The class it relates to (if found)
-
hasExtension
Accessor for whether the query being generated has the specified extension.- Parameters:
key
- Extension name- Returns:
- Whether it is present
-
getValueForExtension
Accessor for the value of the specified query extension (or null if not defined).- Parameters:
key
- Extension name- Returns:
- The value for the extension
-