org.sql.generation.api.grammar.builders.query
Interface SimpleQueryBuilder

All Superinterfaces:
AbstractBuilder<QueryExpression>, AbstractQueryBuilder<QueryExpression>

public interface SimpleQueryBuilder
extends AbstractQueryBuilder<QueryExpression>

This is builder to quickly create simple queries, without the generic and not-so-easy-to-use methods of traditional QuerySpecificationBuilder + QueryFactory style. Using this builder is generally not thread-safe.

Author:
Stanislav Muhametsin

Method Summary
 SimpleQueryBuilder as(String columnAlias)
          Adds alias to the most recently added column.
 SimpleQueryBuilder from(TableName... tableNames)
          Adds table names for FROM clause of this query.
 SimpleQueryBuilder groupBy(String... columns)
          Adds GROUP BY columns for this query.
 SimpleQueryBuilder having(BooleanExpression groupingCondition)
          Adds HAVING grouping condition for this query.
 SimpleQueryBuilder limit()
          Adds the FETCH FIRST ROW ONLY expression for this query.
 SimpleQueryBuilder limit(Integer max)
          Adds the FETCH FIRST <number> ROWS ONLY expression for this query.
 SimpleQueryBuilder limit(NonBooleanExpression max)
          Adds the FETCH FIRST <number> ROWS ONLY expression for this query.
 SimpleQueryBuilder offset(Integer skip)
          Adds the OFFSET <number> ROWS expression for this query.
 SimpleQueryBuilder offset(NonBooleanExpression skip)
          Adds the OFFSET <number> ROWS expression for this query.
 SimpleQueryBuilder orderByAsc(String... columns)
          Adds ORDER BY columns for this query, with ASC as ordering specification.
 SimpleQueryBuilder orderByDesc(String... columns)
          Adds ORDER BY columns for this query, with DESC as ordering specification.
 SimpleQueryBuilder select(String... columnNames)
          Adds the specified columns to the SELECT list.
 SimpleQueryBuilder select(ValueExpression... expressions)
          Adds the specified column expressions to the SELECT list.
 SimpleQueryBuilder selectAllColumns()
          Selects all columns (SELECT *).
 SimpleQueryBuilder where(BooleanExpression searchCondition)
          Sets the search condition (WHERE clause) for this query.
 
Methods inherited from interface org.sql.generation.api.grammar.builders.AbstractBuilder
createExpression
 

Method Detail

select

SimpleQueryBuilder select(String... columnNames)
Adds the specified columns to the SELECT list.

Parameters:
columnNames - The names of the columns.
Returns:
This builder.

select

SimpleQueryBuilder select(ValueExpression... expressions)
Adds the specified column expressions to the SELECT list.

Parameters:
expressions - The value expressions for columns.
Returns:
This builder.

selectAllColumns

SimpleQueryBuilder selectAllColumns()
Selects all columns (SELECT *).

Returns:
This builder.

as

SimpleQueryBuilder as(String columnAlias)
Adds alias to the most recently added column.

Parameters:
columnAlias - The alias for most recently added column;
Returns:
This builder.

from

SimpleQueryBuilder from(TableName... tableNames)
Adds table names for FROM clause of this query.

Parameters:
tableNames - The table names to add.
Returns:
This builder.

where

SimpleQueryBuilder where(BooleanExpression searchCondition)
Sets the search condition (WHERE clause) for this query.

Parameters:
searchCondition - The search condition for this query.
Returns:
This builder.

groupBy

SimpleQueryBuilder groupBy(String... columns)
Adds GROUP BY columns for this query.

Parameters:
columns - The column names for GROUP BY clause.
Returns:
This builder.

having

SimpleQueryBuilder having(BooleanExpression groupingCondition)
Adds HAVING grouping condition for this query.

Parameters:
groupingCondition - The grouping condition for this query.
Returns:
This builder.

orderByAsc

SimpleQueryBuilder orderByAsc(String... columns)
Adds ORDER BY columns for this query, with ASC as ordering specification.

Parameters:
columns - The column names for ORDER BY.
Returns:
This builder.

orderByDesc

SimpleQueryBuilder orderByDesc(String... columns)
Adds ORDER BY columns for this query, with DESC as ordering specification.

Parameters:
columns - The column names for ORDER BY.
Returns:
This builder.

limit

SimpleQueryBuilder limit()
Description copied from interface: AbstractQueryBuilder
Adds the FETCH FIRST ROW ONLY expression for this query. The resulting LimitSpecification will have its count as null.

Specified by:
limit in interface AbstractQueryBuilder<QueryExpression>
Returns:
This builder.

limit

SimpleQueryBuilder limit(Integer max)
Description copied from interface: AbstractQueryBuilder
Adds the FETCH FIRST <number> ROWS ONLY expression for this query. Calling this method is equivalent of calling AbstractQueryBuilder.limit(NonBooleanExpression) and passing the NumericLiteral representing the given number as the parameter.

Specified by:
limit in interface AbstractQueryBuilder<QueryExpression>
Parameters:
max - The maximum amount of rows for this query to return. Use null to remove the FETCH FIRST <number> ROWS ONLY expression.
Returns:
This builder.

limit

SimpleQueryBuilder limit(NonBooleanExpression max)
Description copied from interface: AbstractQueryBuilder
Adds the FETCH FIRST <number> ROWS ONLY expression for this query.

Specified by:
limit in interface AbstractQueryBuilder<QueryExpression>
Parameters:
max - The maximum amount of rows for this query to return. May be subquery or something else that evaluates to number or NULL. Use null to remove the FETCH FIRST <number> ROWS ONLY expression.
Returns:
This builder.

offset

SimpleQueryBuilder offset(Integer skip)
Description copied from interface: AbstractQueryBuilder
Adds the OFFSET <number> ROWS expression for this query. Calling this method is equivalen of calling AbstractQueryBuilder.offset(NonBooleanExpression) and passing the NumericLiteral representing the given number as the parameter.

Specified by:
offset in interface AbstractQueryBuilder<QueryExpression>
Parameters:
skip - The amount of rows to skip before starting to include them into this query. Use null to remove the OFFSET <number> ROWS expression.
Returns:
This builder.

offset

SimpleQueryBuilder offset(NonBooleanExpression skip)
Description copied from interface: AbstractQueryBuilder
Adds the OFFSET <number> ROWS expression for this query.

Specified by:
offset in interface AbstractQueryBuilder<QueryExpression>
Parameters:
skip - The amount of rows to skip before starting to include them into this query. May be subquery or something else that evaluates to number or NULL. Use null to remove the OFFSET <number> ROWS expression.
Returns:
This builder.


Copyright © 2010-2012. All Rights Reserved.