Interface SqlDialect

  • All Known Implementing Classes:
    AnsiDialect

    public interface SqlDialect
    Represents a SQL syntax from a specific database. The implementations provider correct syntax to execute a paging query, that limits the number of rows returned and SQL to count of total records.

    Note: The implementation MUST BE state-less and thread-safe because one instance parse all queries from one Repository.

    Since:
    0.6.0
    Author:
    Alisson Gomes
    • Method Detail

      • name

        String name()
        Dialect name
        Returns:
        the dialect name
      • supportsFeature

        boolean supportsFeature​(SqlFeatureSupport feature)
        verify if dialect instance supports feature specified
        Parameters:
        feature - to check
        Returns:
        true when the dialect supports, false otherwise
      • supportsParmMark

        boolean supportsParmMark​(ParamMarkType paramParse)
        verify if dialect supports a specific ParamMarkType
        Parameters:
        paramParse - parameter mark type
        Returns:
        true when the parse type is supported, false otherwise
      • addFeature

        SqlFeature addFeature​(SqlFeature sqlFeature)
        Override a SQL ANSI feature
        Parameters:
        sqlFeature - override a SqlFeature supports.
        Returns:
        the previous value associated with key sqlFeature
      • getMaxOfParameters

        int getMaxOfParameters()
        Return the limit of elements in an INPUT parameter the database supports.
        Returns:
        the limit of parameters from statement, default is a big number Integer.MAX_VALUE
      • setMaxOfParameters

        void setMaxOfParameters​(int max)
        Max number of parameters supported by JDBC driver
        Parameters:
        max - maximum value of parameter in the query
      • getSqlPatternCount

        String getSqlPatternCount()
        The template to mount the COUNT SQL
        Returns:
        a string template, like that: select count(1) from (%1$s) _alias_internal_table_
      • getSqlPatternPaging

        String getSqlPatternPaging()
        The template to mount the SQL paginated, using LIMIT and OFFSET clauses according the specific database
        Returns:
        a string template, like that: %1$s LIMIT %2$s, %3$s
      • buildQueryPaging

        String buildQueryPaging​(String sqlText,
                                int offset,
                                int max)
        Build a paginate query accordingly data base dialect
        Parameters:
        sqlText - final SQL with parameters to bind
        offset - number from first row from query result
        max - maximum number of rows from query result.
        Returns:
        paginate query for specific data base dialect
      • buildQueryPaging

        String buildQueryPaging​(String sqlText,
                                int offset,
                                int max,
                                String bookmark)
        Build a paginate query accordingly data base dialect
        Parameters:
        sqlText - final SQL with parameters to bind
        offset - number from first row from query result
        max - maximum number of rows from query result.
        bookmark - a page selected marked the reader's place
        Returns:
        paginate query for specific data base dialect
      • buildQueryCount

        String buildQueryCount​(String sqlText)
        Build a paginate query to count the total of records from sqlText
        Parameters:
        sqlText - original SQL to discover the total of records
        Returns:
        query that count the total of records from sqlText
      • getAccessId

        net.sf.jkniv.reflect.beans.PropertyAccess getAccessId()
        The access name for id field, the identifier from an entity
        Returns:
        the property access, default access values are: id, getId, setId
      • getAccessRevision

        net.sf.jkniv.reflect.beans.PropertyAccess getAccessRevision()
        The access name for revision field, a revision number from an entity
        Returns:
        the property access, default access values are: rev, getRev, setRev