Interface IQueryRewriter
-
- All Known Implementing Classes:
AbstractQueryRewriter,DB2QueryRewriter,DefaultQueryRewriter,H2QueryRewriter,Hive2QueryRewriter,HiveQueryRewriter,HsqldbQueryRewriter,ImpalaQueryRewriter,LimitOffsetQueryRewriter,MysqlQueryRewriter,OffsetFetchQueryRewriter,OracleQueryRewriter,PostgresqlQueryRewriter,RowNumberQueryRewriter,SQLiteQueryRewriter,SQLServerQueryRewriter
public interface IQueryRewriterA query rewriter can be used for rewriting (part of) a query's string representation. This is usefull for databases that deviate from the SQL 99 compliant syntax which is delievered by the query and it's query item's toString() methods.- See Also:
AbstractQueryRewriter,JdbcDataContext
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringescapeQuotes(String item)Escapes the quotes within a String literal of a query item.org.apache.metamodel.schema.ColumnTypegetColumnType(int jdbcType, String nativeType, Integer columnSize)Gets the column type for a specific JDBC type (as defined inTypes), native type name and column size.ObjectgetResultSetValue(ResultSet resultSet, int columnIndex, org.apache.metamodel.schema.Column column)Retrieves a value from a JDBCResultSetwhen the anticipated value is mapped to a particular column.booleanisAggregateFunctionSupported(org.apache.metamodel.query.AggregateFunction function)Determines whether a specific aggregate function is supported by the database or not.booleanisFirstRowSupported(org.apache.metamodel.query.Query query)Gets whether this query rewriter is able to write the "First row" query property to the query string.booleanisMaxRowsSupported()Gets whether this query rewriter is able to write the "Max rows" query property to the query string.booleanisPrimaryKeySupported()Determines if the JDBC data source supports primary keys or not.booleanisScalarFunctionSupported(org.apache.metamodel.query.ScalarFunction function)Determines whether a specific scalar function is supported by the database or not.booleanisTransactional()Determines if the JDBC data source supports transactions or not.StringrewriteColumnType(org.apache.metamodel.schema.ColumnType columnType, Integer columnSize)Rewrites the name of a column type, as it is written in CREATE TABLE statements.StringrewriteFilterItem(org.apache.metamodel.query.FilterItem whereItem)StringrewriteFromItem(org.apache.metamodel.query.FromItem item)StringrewriteQuery(org.apache.metamodel.query.Query query)voidsetStatementParameter(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 thePreparedStatement.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 JDBCResultSetwhen 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)ColumnTypeto rewritecolumnSize- 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 inTypes), 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:
-
-