org.sql.generation.api.grammar.factories
Interface QueryFactory


public interface QueryFactory

A factory, which creates builders and syntax elements for SQL queries (SELECT statements). This factory may be obtained from SQLVendor.

Author:
Stanislav Muhametsin
See Also:
SQLVendor, QueryExpression, QuerySpecification

Method Summary
 QueryExpression callFunction(SQLFunctionLiteral function)
          Returns a query for calling a SQL function without a schema.
 QueryExpression callFunction(String schemaName, SQLFunctionLiteral function)
          Returns a query for calling a SQL function with schema.
 ColumnsBuilder columnsBuilder()
           Creates a builder for the columns in SELECT expressions.
 ColumnsBuilder columnsBuilder(SetQuantifier setQuantifier)
          Creates a builder for columns in SELECT expressions, which has specified set quantifier initially.
 QueryExpression createQuery(QueryExpressionBody body)
          Creates new query, which has the specified body as an actual query.
 FromBuilder fromBuilder()
          Creates a builder for FROM clause.
 GroupByBuilder groupByBuilder()
          Creates a builder for GROUP BY clause.
 OrdinaryGroupingSet groupingElement(NonBooleanExpression... expressions)
          Creates a new grouping element, which has some expressions as grouping columns.
 LimitSpecification limit(NonBooleanExpression count)
          Creates a new FETCH FIRST <n> ROWS ONLY syntax element for query.
 OffsetSpecification offset(NonBooleanExpression offset)
          Creates a new OFFSET <n> ROWS syntax element for query.
 OrderByBuilder orderByBuilder()
          Creates a builder for ORDER BY clause.
 QueryBuilder queryBuilder()
           Creates a builder to build queries with capability for UNION, INTERSECT, and EXCEPT set operations.
 QueryBuilder queryBuilder(QueryExpressionBody query)
          Creates a builder to build queries with capability for UNION, INTERSECT, and EXCEPT set operations.
 QuerySpecificationBuilder querySpecificationBuilder()
          Creates a builder to build query specifications (SELECT expressions).
 RowDefinition row(ValueExpression... elements)
          Creates a new row for VALUES expression in query.
 RowSubQuery rowSubQuery(QueryExpression subQuery)
          Creates a new subquery for a row for VALUES expression in query.
 SimpleQueryBuilder simpleQueryBuilder()
          Creates a builder for simple queries.
 SortSpecification sortSpec(ValueExpression expression, Ordering ordering)
          Creates a new sort specification for ORDER BY clause.
 TableValueConstructor values(RowValueConstructor... rows)
          Creates a new VALUES expression in query.
 

Method Detail

createQuery

QueryExpression createQuery(QueryExpressionBody body)
Creates new query, which has the specified body as an actual query.

Parameters:
body - The actual query to use.
Returns:
The new QueryExpression

querySpecificationBuilder

QuerySpecificationBuilder querySpecificationBuilder()
Creates a builder to build query specifications (SELECT expressions).

Returns:
The new QuerySpecificationBuilder.

columnsBuilder

ColumnsBuilder columnsBuilder()

Creates a builder for the columns in SELECT expressions.

Calling this method is equivalent to calling columnsBuilder(SetQuantifier) and passing SetQuantifier.ALL as argument.

Returns:
The new ColumnsBuilder.

columnsBuilder

ColumnsBuilder columnsBuilder(SetQuantifier setQuantifier)
Creates a builder for columns in SELECT expressions, which has specified set quantifier initially.

Parameters:
setQuantifier - The set quantifier to use.
Returns:
The new ColumnsBuilder.

queryBuilder

QueryBuilder queryBuilder()

Creates a builder to build queries with capability for UNION, INTERSECT, and EXCEPT set operations.

Calling this method is equivalent in calling queryBuilder(QueryExpressionBody) and passing QueryExpressionBody.EmptyQueryExpressionBody as argument.

Returns:
The new QueryBuilder.

queryBuilder

QueryBuilder queryBuilder(QueryExpressionBody query)
Creates a builder to build queries with capability for UNION, INTERSECT, and EXCEPT set operations.

Parameters:
query - The initial query for builder.
Returns:
The new QueryBuilder.

groupByBuilder

GroupByBuilder groupByBuilder()
Creates a builder for GROUP BY clause.

Returns:
The new GroupByBuilder.

fromBuilder

FromBuilder fromBuilder()
Creates a builder for FROM clause.

Returns:
The new FromBuilder.

groupingElement

OrdinaryGroupingSet groupingElement(NonBooleanExpression... expressions)
Creates a new grouping element, which has some expressions as grouping columns.

Parameters:
expressions - The expressions to use.
Returns:
The new OrdinaryGroupingSet.
See Also:
GroupByClause

sortSpec

SortSpecification sortSpec(ValueExpression expression,
                           Ordering ordering)
Creates a new sort specification for ORDER BY clause.

Parameters:
expression - The expression for column.
ordering - The ordering to use.
Returns:
The new SortSpecification.

orderByBuilder

OrderByBuilder orderByBuilder()
Creates a builder for ORDER BY clause.

Returns:
The new OrderByBuilder.

simpleQueryBuilder

SimpleQueryBuilder simpleQueryBuilder()
Creates a builder for simple queries.

Returns:
The new SimpleQueryBuilder.

values

TableValueConstructor values(RowValueConstructor... rows)
Creates a new VALUES expression in query.

Parameters:
rows - The rows for VALUES expression.
Returns:
The new TableValueConstructor.
See Also:
RowValueConstructor, RowSubQuery, RowDefinition

rowSubQuery

RowSubQuery rowSubQuery(QueryExpression subQuery)
Creates a new subquery for a row for VALUES expression in query.

Parameters:
subQuery - The query to return the row.
Returns:
The new RowSubQuery.

row

RowDefinition row(ValueExpression... elements)
Creates a new row for VALUES expression in query.

Parameters:
elements - The elements for the row.
Returns:
The new RowDefinition.

callFunction

QueryExpression callFunction(String schemaName,
                             SQLFunctionLiteral function)
Returns a query for calling a SQL function with schema. The query is SELECT * FROM schemaName.functionName(params...).

Parameters:
schemaName - The name of the schema where SQL function resides.
function - The SQL function to call.
Returns:
A query returning the results of calling SQL function.

callFunction

QueryExpression callFunction(SQLFunctionLiteral function)
Returns a query for calling a SQL function without a schema. The query is SELECT * FROM functionName(params...). Calling this method is equivalent to calling callFunction(String, SQLFunctionLiteral) and passing null as first argument.

Parameters:
function - The function to call.
Returns:
A query returning the results of calling SQL function.

offset

OffsetSpecification offset(NonBooleanExpression offset)
Creates a new OFFSET <n> ROWS syntax element for query.

Parameters:
offset - The offset amount.
Returns:
A new OFFSET <n> ROWS syntax element.

limit

LimitSpecification limit(NonBooleanExpression count)
Creates a new FETCH FIRST <n> ROWS ONLY syntax element for query.

Parameters:
count - The limit amount.
Returns:
A new FETCH FIRST <n> ROWS ONLY syntax element.


Copyright © 2010-2012. All Rights Reserved.