Interface IQueryRewriter

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String escapeQuotes​(String item)
      Escapes the quotes within a String literal of a query item.
      org.apache.metamodel.schema.ColumnType getColumnType​(int jdbcType, String nativeType, Integer columnSize)
      Gets the column type for a specific JDBC type (as defined in Types), native type name and column size.
      Object getResultSetValue​(ResultSet resultSet, int columnIndex, org.apache.metamodel.schema.Column column)
      Retrieves a value from a JDBC ResultSet when the anticipated value is mapped to a particular column.
      boolean isAggregateFunctionSupported​(org.apache.metamodel.query.AggregateFunction function)
      Determines whether a specific aggregate function is supported by the database or not.
      boolean isFirstRowSupported​(org.apache.metamodel.query.Query query)
      Gets whether this query rewriter is able to write the "First row" query property to the query string.
      boolean isMaxRowsSupported()
      Gets whether this query rewriter is able to write the "Max rows" query property to the query string.
      boolean isPrimaryKeySupported()
      Determines if the JDBC data source supports primary keys or not.
      boolean isScalarFunctionSupported​(org.apache.metamodel.query.ScalarFunction function)
      Determines whether a specific scalar function is supported by the database or not.
      boolean isTransactional()
      Determines if the JDBC data source supports transactions or not.
      String rewriteColumnType​(org.apache.metamodel.schema.ColumnType columnType, Integer columnSize)
      Rewrites the name of a column type, as it is written in CREATE TABLE statements.
      String rewriteFilterItem​(org.apache.metamodel.query.FilterItem whereItem)  
      String rewriteFromItem​(org.apache.metamodel.query.FromItem item)  
      String rewriteQuery​(org.apache.metamodel.query.Query query)  
      void setStatementParameter​(PreparedStatement st, int valueIndex, org.apache.metamodel.schema.Column column, Object value)
      Method which handles the action of setting a parameterized value on a statement.
    • Method Detail

      • rewriteFromItem

        String rewriteFromItem​(org.apache.metamodel.query.FromItem item)
      • rewriteQuery

        String rewriteQuery​(org.apache.metamodel.query.Query query)
      • rewriteFilterItem

        String rewriteFilterItem​(org.apache.metamodel.query.FilterItem whereItem)
      • setStatementParameter

        void setStatementParameter​(PreparedStatement st,
                                   int valueIndex,
                                   org.apache.metamodel.schema.Column column,
                                   Object value)
                            throws SQLException
        Method which handles the action of setting a parameterized value on a statement. Traditionally this is done using the PreparedStatement.setObject(int, Object) method but for some types we use more specific setter methods.
        Parameters:
        st -
        valueIndex -
        column -
        value -
        Throws:
        SQLException
      • getResultSetValue

        Object getResultSetValue​(ResultSet resultSet,
                                 int columnIndex,
                                 org.apache.metamodel.schema.Column column)
                          throws SQLException
        Retrieves a value from a JDBC ResultSet when the anticipated value is mapped to a particular column.
        Parameters:
        resultSet -
        columnIndex -
        column -
        Returns:
        Throws:
        SQLException
      • isMaxRowsSupported

        boolean isMaxRowsSupported()
        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.
      • isFirstRowSupported

        boolean isFirstRowSupported​(org.apache.metamodel.query.Query query)
        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.
      • isScalarFunctionSupported

        boolean isScalarFunctionSupported​(org.apache.metamodel.query.ScalarFunction function)
        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.
        Parameters:
        function -
        Returns:
      • isAggregateFunctionSupported

        boolean isAggregateFunctionSupported​(org.apache.metamodel.query.AggregateFunction function)
        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.
        Parameters:
        function -
        Returns:
      • escapeQuotes

        String escapeQuotes​(String item)
        Escapes the quotes within a String literal of a query item.
        Returns:
        String item with quotes escaped.
      • rewriteColumnType

        String rewriteColumnType​(org.apache.metamodel.schema.ColumnType columnType,
                                 Integer columnSize)
        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.
        Parameters:
        columnType - the (non-null) ColumnType to rewrite
        columnSize - the (possibly null) column size that may or may not have been specified
        Returns:
      • getColumnType

        org.apache.metamodel.schema.ColumnType getColumnType​(int jdbcType,
                                                             String nativeType,
                                                             Integer columnSize)
        Gets the column type for a specific JDBC type (as defined in Types), native type name and column size.
        Parameters:
        jdbcType -
        nativeType -
        columnSize -
        Returns:
      • isTransactional

        boolean isTransactional()
        Determines if the JDBC data source supports transactions or not. Usually this is the case since JDBC is designed for ACID compliant databases, but in some cases the JDBC interface is used also to facilitate connectivity to non-transactional data source such as Apache Hive and others.
        Returns:
      • isPrimaryKeySupported

        boolean isPrimaryKeySupported()
        Determines if the JDBC data source supports primary keys or not.
        Returns: