Interface Sql

  • All Known Subinterfaces:
    Deletable, Insertable, Selectable, SqlTag, Updateable
    All Known Implementing Classes:
    AbstractSqlTag, IncludeTag, ProcedureTag

    public interface Sql
    This interface represent Structured Query Language (SQL and some derivations like JPQL, HQL, JPQL, CQL...) in XML file, each node at XML file is represented by this class.

    Those queries can be dynamic or static and to recover a dynamic query (built on-the-fly) is necessary to pass the parameters that can be mounted dynamically.

    Since:
    0.6.0
    Author:
    Alisson Gomes
    • Method Detail

      • getName

        String getName()
        The name of query into XML file
        Returns:
        query name
      • getSql

        String getSql()
        Retrieve static SQL from a node, the dynamic parts is skipped.
        Returns:
        SQL sentence
      • getSql

        String getSql​(Object params)
        Retrieve dynamic SQL from a node, the dynamic parts is evaluated at time to create the SQL.
        Parameters:
        params - parameters to evaluate dynamic SQL, can be a object like Author, Book, etc or a java.util.Map where yours keys is like the properties.
        Returns:
        Dynamic SQL sentence
      • getSqlType

        SqlType getSqlType()
        Retrieve node type: INSERT, UPDATE, DELETE, SELECT or PROCEDURE.
        Returns:
        node type declared at XML file.
      • isSelectable

        boolean isSelectable()
        Verify if command is a SELECT
        Returns:
        true when is SELECT, false otherwise
      • isInsertable

        boolean isInsertable()
        Verify if command is a INSERT
        Returns:
        true when is INSERT, false otherwise
      • isUpdateable

        boolean isUpdateable()
        Verify if command is a UPDATE
        Returns:
        true when is UPDATE, false otherwise
      • isDeletable

        boolean isDeletable()
        Verify if command is a DELETE
        Returns:
        true when is DELETE, false otherwise
      • isStorable

        boolean isStorable()
        Verify if command is a STORED PROCEDURE
        Returns:
        true when is STORED PROCEDURE, false otherwise
      • getLanguageType

        LanguageType getLanguageType()
        Retrieve the language type used at sql sentence.
        Returns:
        language type declared at xml file.
      • getIsolation

        Isolation getIsolation()
        Retrieves the current transaction isolation level for the query.
        Returns:
        the current transaction isolation level.
      • getTimeout

        int getTimeout()
        Retrieves the number of seconds the repository will wait for a Query object to execute. If the limit is exceeded, a RepositoryException is thrown.
        Returns:
        the current query timeout limit in seconds; zero means there is no limit
      • getReturnType

        String getReturnType()
      • hasReturnType

        boolean hasReturnType()
      • getReturnTypeAsClass

        Class<?> getReturnTypeAsClass()
      • getTimestamp

        Date getTimestamp()
        Timestamp when sql was read from xml
        Returns:
        when SQL was read from XML file
      • getResourceName

        String getResourceName()
        The filename that SQL belong to
        Returns:
        return the filename, relative to absolute classpath, where the SQL was read.
      • getXPath

        String getXPath()
        Expression XPATH to read SQL
        Returns:
        the XPATH expression to read the SQL at XML file.
      • getParamParser

        ParamParser getParamParser()
        strategy to parser the parameters from SQL.
        Returns:
        return the implementation of parser (colon, hash or question mark)
      • extractNames

        String[] extractNames​(Object params)
        Extract the name parameters from dynamic query
        Parameters:
        params - parameters from query
        Returns:
        array of parameters names from query, array based-zero length when haven't param. Array of questions marks (?) is returned when the isn't name based.
      • extractNames

        String[] extractNames​(String sql)
        Extract the name parameters from SQL
        Parameters:
        sql - sentence
        Returns:
        array of parameters names from query, array based-zero length when haven't param. Array of questions marks (?) is returned when the isn't name based.
      • setValidateType

        void setValidateType​(ValidateType validateType)
      • getSqlDialect

        SqlDialect getSqlDialect()
        dialect for a specific database
        Returns:
        the dialect
      • getPackage

        String getPackage()
        name of package that this SQL belongs
        Returns:
        name of package
      • getStats

        Statistical getStats()
        get statistical data from query execution
        Returns:
        the statistical like min/max/avg times.