Interface QueryGenerator

  • All Known Implementing Classes:
    QueryToSQLMapper

    public interface QueryGenerator
    Interface for a generator of query statements.
    • Method Detail

      • 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

        Object getProperty​(String name)
        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

        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).
        Parameters:
        paramLiteral - The parameter expression
      • getTypeOfVariable

        Class getTypeOfVariable​(String varName)
        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 name
        cmd - Metadata for this variable type
        sqlTbl - Table for this variable
        mapping - The mapping of this variable in the table
      • bindVariable

        SQLExpression bindVariable​(UnboundExpression expr,
                                   Class type)
        Method to bind the specified unbound variable (as cross join).
        Parameters:
        expr - Unbound expression
        type - 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

        void bindParameter​(String paramName,
                           Class type)
        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 parameter
        type - The type (or subclass)
      • resolveClass

        Class resolveClass​(String className)
        Convenience method to resolve a class name.
        Parameters:
        className - The class name
        Returns:
        The class it relates to (if found)
      • hasExtension

        boolean hasExtension​(String key)
        Accessor for whether the query being generated has the specified extension.
        Parameters:
        key - Extension name
        Returns:
        Whether it is present
      • getValueForExtension

        Object getValueForExtension​(String key)
        Accessor for the value of the specified query extension (or null if not defined).
        Parameters:
        key - Extension name
        Returns:
        The value for the extension