Class AnsiDialect

  • All Implemented Interfaces:
    SqlDialect

    public class AnsiDialect
    extends Object
    implements SqlDialect
    Represents the support from SQL ANSI that are queries cross-platform. Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility with different systems. Subclasses should provide a public default constructor that register a set of type mappings and default Hibernate properties. Subclasses should be immutable.
    • Supports limits? false
    • Supports limit off set? false
    • Supports rownum? false
    Author:
    Alisson Gomes
    • Field Detail

      • patternORDER_BY

        public static final Pattern patternORDER_BY
    • Constructor Detail

      • AnsiDialect

        public AnsiDialect()
    • Method Detail

      • name

        public String name()
        Description copied from interface: SqlDialect
        Dialect name
        Specified by:
        name in interface SqlDialect
        Returns:
        the dialect name
      • supportsFeature

        public boolean supportsFeature​(SqlFeatureSupport feature)
        Description copied from interface: SqlDialect
        verify if dialect instance supports feature specified
        Specified by:
        supportsFeature in interface SqlDialect
        Parameters:
        feature - to check
        Returns:
        true when the dialect supports, false otherwise
      • supportsParmMark

        public boolean supportsParmMark​(ParamMarkType paramParse)
        Description copied from interface: SqlDialect
        verify if dialect supports a specific ParamMarkType
        Specified by:
        supportsParmMark in interface SqlDialect
        Parameters:
        paramParse - parameter mark type
        Returns:
        true when the parse type is supported, false otherwise
      • addFeature

        public SqlFeature addFeature​(SqlFeature sqlFeature)
        Description copied from interface: SqlDialect
        Override a SQL ANSI feature
        Specified by:
        addFeature in interface SqlDialect
        Parameters:
        sqlFeature - override a SqlFeature supports.
        Returns:
        the previous value associated with key sqlFeature
      • getMaxOfParameters

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

        public void setMaxOfParameters​(int max)
        Description copied from interface: SqlDialect
        Max number of parameters supported by JDBC driver
        Specified by:
        setMaxOfParameters in interface SqlDialect
        Parameters:
        max - maximum value of parameter in the query
      • getSqlPatternCount

        public String getSqlPatternCount()
        Description copied from interface: SqlDialect
        The template to mount the COUNT SQL
        Specified by:
        getSqlPatternCount in interface SqlDialect
        Returns:
        a string template, like that: select count(1) from (%1$s) _alias_internal_table_
      • getSqlPatternPaging

        public String getSqlPatternPaging()
        Description copied from interface: SqlDialect
        The template to mount the SQL paginated, using LIMIT and OFFSET clauses according the specific database
        Specified by:
        getSqlPatternPaging in interface SqlDialect
        Returns:
        a string template, like that: %1$s LIMIT %2$s, %3$s
      • buildQueryPaging

        public String buildQueryPaging​(String sqlText,
                                       int offset,
                                       int max)
        Description copied from interface: SqlDialect
        Build a paginate query accordingly data base dialect
        Specified by:
        buildQueryPaging in interface SqlDialect
        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

        public String buildQueryPaging​(String sqlText,
                                       int offset,
                                       int max,
                                       String bookmark)
        Description copied from interface: SqlDialect
        Build a paginate query accordingly data base dialect
        Specified by:
        buildQueryPaging in interface SqlDialect
        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
      • getAccessId

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

        public net.sf.jkniv.reflect.beans.PropertyAccess getAccessRevision()
        Description copied from interface: SqlDialect
        The access name for revision field, a revision number from an entity
        Specified by:
        getAccessRevision in interface SqlDialect
        Returns:
        the property access, default access values are: rev, getRev, setRev
      • buildQueryCount

        public String buildQueryCount​(String sqlText)
        Description copied from interface: SqlDialect
        Build a paginate query to count the total of records from sqlText
        Specified by:
        buildQueryCount in interface SqlDialect
        Parameters:
        sqlText - original SQL to discover the total of records
        Returns:
        query that count the total of records from sqlText
      • sqlStartWithSelect

        protected Matcher sqlStartWithSelect​(String sql)
      • sqlStartWithSelectOrDistinct

        protected Matcher sqlStartWithSelectOrDistinct​(String sql)
      • sqlEndsWithOrderBy

        protected Matcher sqlEndsWithOrderBy​(String sql)
      • sqlEndWithForUpdate

        protected Matcher sqlEndWithForUpdate​(String sql)
      • countOccurrencesOf

        protected int countOccurrencesOf​(String str,
                                         String sub)
        Count the occurrences of the substring in string s.
        Parameters:
        str - string to search in. Return 0 if this is null.
        sub - string to search for. Return 0 if this is null.
        Returns:
        number of occurrences from str