Class DefaultQueryRewriter

    • Constructor Detail

      • DefaultQueryRewriter

        public DefaultQueryRewriter​(JdbcDataContext dataContext)
    • Method Detail

      • beforeRewrite

        protected org.apache.metamodel.query.Query beforeRewrite​(org.apache.metamodel.query.Query query)
        Description copied from class: AbstractQueryRewriter
        Method to modify query before rewriting begins. Overwrite this method if you want to change parts of the query that are not just rendering related. Cloning the query before modifying is recommended in order to not violate referential integrity of clients (the query is mutable).
        Overrides:
        beforeRewrite in class AbstractQueryRewriter
        Returns:
        the modified query
      • rewriteColumnType

        public String rewriteColumnType​(org.apache.metamodel.schema.ColumnType columnType,
                                        Integer columnSize)
        Description copied from interface: IQueryRewriter
        Rewrites the name of a column type, as it is written in CREATE TABLE statements. Some databases dont support all column types, or have different names for them. The implementation of this method will do that conversion.
        Specified by:
        rewriteColumnType in interface IQueryRewriter
        Overrides:
        rewriteColumnType in class AbstractQueryRewriter
        Parameters:
        columnType - the (non-null) ColumnType to rewrite
        columnSize - the (possibly null) column size that may or may not have been specified
        Returns:
      • needsQuoting

        protected boolean needsQuoting​(String alias,
                                       String identifierQuoteString)
      • rewriteFilterItemWithOperandLiteral

        protected String rewriteFilterItemWithOperandLiteral​(org.apache.metamodel.query.FilterItem item,
                                                             String operandLiteral)
        Rewrites a (non-compound) FilterItem when it's operand has already been rewritten into a SQL literal.
        Parameters:
        item -
        operandLiteral -
        Returns:
      • rewriteTimestamp

        protected String rewriteTimestamp​(Timestamp ts)
        Rewrites a Timestamp into it's literal representation as known by this SQL dialect. This default implementation returns the JDBC spec's escape syntax for a timestamp: {ts 'yyyy-mm-dd hh:mm:ss.f . . .'}
        Parameters:
        ts -
        Returns:
      • isScalarFunctionSupported

        public boolean isScalarFunctionSupported​(org.apache.metamodel.query.ScalarFunction function)
        Description copied from interface: IQueryRewriter
        Determines whether a specific scalar function is supported by the database or not. If the function is not supported then MetaModel will handle the function on the client side.
        Returns:
      • isAggregateFunctionSupported

        public boolean isAggregateFunctionSupported​(org.apache.metamodel.query.AggregateFunction function)
        Description copied from interface: IQueryRewriter
        Determines whether a specific aggregate function is supported by the database or not. If the function is not supported then MetaModel will handle the function on the client side.
        Returns:
      • isFirstRowSupported

        public boolean isFirstRowSupported​(org.apache.metamodel.query.Query query)
        Description copied from interface: IQueryRewriter
        Gets whether this query rewriter is able to write the "First row" query property to the query string.
        Parameters:
        query - For some database engines, the content of the query decides the ability to change first row
        Returns:
        whether this query rewriter is able to write the "First row" query property to the query string.
      • isMaxRowsSupported

        public boolean isMaxRowsSupported()
        Description copied from interface: IQueryRewriter
        Gets whether this query rewriter is able to write the "Max rows" query property to the query string.
        Returns:
        whether this query rewriter is able to write the "Max rows" query property to the query string.
      • escapeQuotes

        public String escapeQuotes​(String item)
        Description copied from interface: IQueryRewriter
        Escapes the quotes within a String literal of a query item.
        Returns:
        String item with quotes escaped.
      • isPrimaryKeySupported

        public boolean isPrimaryKeySupported()
        Description copied from interface: IQueryRewriter
        Determines if the JDBC data source supports primary keys or not.
        Returns: