Class AbstractSqlTag

  • All Implemented Interfaces:
    SqlTag, Sql
    Direct Known Subclasses:
    IncludeTag, ProcedureTag

    public abstract class AbstractSqlTag
    extends Object
    implements SqlTag
    Generic tag to support the common functions from other tags.
    Since:
    0.0.2
    Author:
    Alisson Gomes
    • Constructor Detail

      • AbstractSqlTag

        public AbstractSqlTag​(String id,
                              LanguageType languageType)
        Build a new SQL tag from XML file.
        Parameters:
        id - Name/Identify from tag.
        languageType - type of language from tag.
      • AbstractSqlTag

        public AbstractSqlTag​(String id,
                              LanguageType languageType,
                              Isolation isolation,
                              int timeout,
                              ValidateType validateType,
                              Statistical stats)
        Build a new SQL tag from XML file.
        Parameters:
        id - Name/Identify from tag.
        languageType - type of language from tag.
        isolation - Retrieves the current transaction isolation level for the query.
        timeout - Retrieves the number of seconds the repository will wait for a Query object to execute.
        validateType - validation to apply before execute SQL.
        stats - SQL statistical
      • AbstractSqlTag

        public AbstractSqlTag​(String id,
                              LanguageType languageType,
                              Isolation isolation,
                              int timeout,
                              ResultSetType resultSetType,
                              ResultSetConcurrency resultSetConcurrency,
                              ResultSetHoldability resultSetHoldability,
                              String returnType,
                              ValidateType validateType,
                              Statistical stats)
        Build a new SQL tag from XML file.
        Parameters:
        id - Name/Identify from tag.
        languageType - type of language from tag.
        isolation - Retrieves the current transaction isolation level for the query.
        timeout - Retrieves the number of seconds the repository will wait for a Query object to execute.
        resultSetType - TODO javadoc
        resultSetConcurrency - TODO javadoc
        resultSetHoldability - TODO javadoc
        returnType - v
        validateType - TODO javadoc
        stats - statistical for procedures
    • Method Detail

      • getSql

        public String getSql()
        Retrieve static sql from a node, the dynamic parts is skipped.
        Specified by:
        getSql in interface Sql
        Returns:
        Sql sentence
      • getSql

        public String getSql​(Object params)
        Retrieve dynamic sql from a node, the dynamic parts is evaluated at time to create the sql.
        Specified by:
        getSql in interface 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
      • getLanguageType

        public LanguageType getLanguageType()
        language from SQL sentence.
        Specified by:
        getLanguageType in interface Sql
        Returns:
        the type of language used to SQL sentence.
      • getName

        public String getName()
        Retrieve the identifier name from tag.
        Specified by:
        getName in interface Sql
        Specified by:
        getName in interface SqlTag
        Returns:
        name from tag
      • addTag

        public void addTag​(ITextTag tag)
        add a new text tag.
        Specified by:
        addTag in interface SqlTag
        Parameters:
        tag - content as another tag
      • addTag

        public void addTag​(String text)
        add a set of static text from tag elements.
        Specified by:
        addTag in interface SqlTag
        Parameters:
        text - content
      • addTag

        public void addTag​(List<ITextTag> tags)
        add a set of text tags (static or dynamic).
        Specified by:
        addTag in interface SqlTag
        Parameters:
        tags - content as list of text tags
      • getIsolation

        public Isolation getIsolation()
        Description copied from interface: Sql
        Retrieves the current transaction isolation level for the query.
        Specified by:
        getIsolation in interface Sql
        Returns:
        the current transaction isolation level.
      • setIsolation

        public void setIsolation​(Isolation isolation)
      • getTimeout

        public int getTimeout()
        Description copied from interface: Sql
        Retrieves the number of seconds the repository will wait for a Query object to execute. If the limit is exceeded, a RepositoryException is thrown.
        Specified by:
        getTimeout in interface Sql
        Returns:
        the current query timeout limit in seconds; zero means there is no limit
      • setTimeout

        public void setTimeout​(int timeout)
      • isSelectable

        public boolean isSelectable()
        Description copied from interface: Sql
        Verify if command is a SELECT
        Specified by:
        isSelectable in interface Sql
        Returns:
        true when is SELECT, false otherwise
      • isInsertable

        public boolean isInsertable()
        Description copied from interface: Sql
        Verify if command is a INSERT
        Specified by:
        isInsertable in interface Sql
        Returns:
        true when is INSERT, false otherwise
      • isUpdateable

        public boolean isUpdateable()
        Description copied from interface: Sql
        Verify if command is a UPDATE
        Specified by:
        isUpdateable in interface Sql
        Returns:
        true when is UPDATE, false otherwise
      • isDeletable

        public boolean isDeletable()
        Description copied from interface: Sql
        Verify if command is a DELETE
        Specified by:
        isDeletable in interface Sql
        Returns:
        true when is DELETE, false otherwise
      • isStorable

        public boolean isStorable()
        Description copied from interface: Sql
        Verify if command is a STORED PROCEDURE
        Specified by:
        isStorable in interface Sql
        Returns:
        true when is STORED PROCEDURE, false otherwise
      • asStorable

        public Storable asStorable()
        Description copied from interface: Sql
        Storable instance
        Specified by:
        asStorable in interface Sql
        Returns:
        this instance
      • setResultSetType

        public void setResultSetType​(ResultSetType resultSetType)
      • setResultSetConcurrency

        public void setResultSetConcurrency​(ResultSetConcurrency resultSetConcurrency)
      • setResultSetHoldability

        public void setResultSetHoldability​(ResultSetHoldability resultSetHoldability)
      • setResultType

        public void setResultType​(String returnType)
      • hasReturnType

        public boolean hasReturnType()
        Specified by:
        hasReturnType in interface Sql
      • setXpath

        public void setXpath​(String xpath)
        Description copied from interface: SqlTag
        set the XPATH expression to retrieve the query at xml file.
        Specified by:
        setXpath in interface SqlTag
        Parameters:
        xpath - expression
      • getXPath

        public String getXPath()
        Description copied from interface: Sql
        Expression XPATH to read SQL
        Specified by:
        getXPath in interface Sql
        Returns:
        the XPATH expression to read the SQL at XML file.
      • setResourceName

        public void setResourceName​(String resourceName)
        Description copied from interface: SqlTag
        File name from Sql
        Specified by:
        setResourceName in interface SqlTag
        Parameters:
        resourceName - filename from sql as resource
      • getResourceName

        public String getResourceName()
        Description copied from interface: Sql
        The filename that SQL belong to
        Specified by:
        getResourceName in interface Sql
        Returns:
        return the filename, relative to absolute classpath, where the SQL was read.
      • getTimestamp

        public Date getTimestamp()
        Description copied from interface: Sql
        Timestamp when sql was read from xml
        Specified by:
        getTimestamp in interface Sql
        Returns:
        when SQL was read from XML file
      • getParamParser

        public ParamParser getParamParser()
        Description copied from interface: Sql
        strategy to parser the parameters from SQL.
        Specified by:
        getParamParser in interface Sql
        Returns:
        return the implementation of parser (colon, hash or question mark)
      • extractNames

        public String[] extractNames​(Object params)
        Description copied from interface: Sql
        Extract the name parameters from dynamic query
        Specified by:
        extractNames in interface Sql
        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

        public String[] extractNames​(String sql)
        Description copied from interface: Sql
        Extract the name parameters from SQL
        Specified by:
        extractNames in interface 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.
      • bind

        public void bind​(SqlDialect sqlDialect)
        Specified by:
        bind in interface Sql
      • getSqlDialect

        public SqlDialect getSqlDialect()
        Description copied from interface: Sql
        dialect for a specific database
        Specified by:
        getSqlDialect in interface Sql
        Returns:
        the dialect
      • getPackage

        public String getPackage()
        Description copied from interface: Sql
        name of package that this SQL belongs
        Specified by:
        getPackage in interface Sql
        Returns:
        name of package
      • setPackage

        public void setPackage​(String name)
        Description copied from interface: SqlTag
        name of package this sql belong
        Specified by:
        setPackage in interface SqlTag
        Parameters:
        name - of package
      • getStats

        public Statistical getStats()
        Description copied from interface: Sql
        get statistical data from query execution
        Specified by:
        getStats in interface Sql
        Returns:
        the statistical like min/max/avg times.
      • setStats

        protected void setStats​(Statistical stats)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object