Class Select
- java.lang.Object
-
- com.ibm.fhir.database.utils.query.Select
-
public class Select extends Object
Representation of a select statement built bySelectAdapter.build()
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumn(String source, String name)Add a single column to the select listvoidaddColumn(String source, String name, Alias alias)Add a single column to the select list, providing an alias for the columnvoidaddColumns(String... columns)Add the list of simple columnsvoidaddFrom(Select sub, Alias alias)Add a sub-select statement with an alias to the from-clausevoidaddHavingPredicate(String predicate)Add a predicate to the HAVING clause for this statementvoidaddInnerJoin(String tableName, Alias alias, ExpNode joinOnPredicate)Add an inner join to the from clause for this select statement.voidaddLeftOuterJoin(String tableName, Alias alias, ExpNode joinOnPredicate)Add a left outer join to the from clause for this select statement.voidaddPagination(int offset, int rowsPerPage)Add a pagination clause (offset/limit) to the query.voidaddTable(String tableName)Add a table item to the from-clausevoidaddTable(String tableName, Alias alias)Add a table item with an alias to the from-clausevoidaddTable(String schemaName, String tableName)Add a table item to the from-clausevoidaddTable(String schemaName, String tableName, Alias alias)Add a schema-qualified table item with an alias to the from clauseOrderByClausegetOrderByClause()WhereClausegetWhereClause()Getter for the whereClause<T> Trender(StatementRenderer<T> renderer)Render the components of the statementstatic SelectAdapterselect(boolean distinct, String... columns)Factory to start building a SELECT DISTINCT statementstatic SelectAdapterselect(String... columns)Factory to create a new instance of the builder needed to create this statementvoidsetGroupByClause(GroupByClause gb)Set the group-by-clause for this statementvoidsetOrderByClause(OrderByClause ob)voidsetWhereClause(WhereClause wc)Set the where-clause for this statementStringtoDebugString()A string representation of the query with the bind variables substituted in place which is handy for debugging - but not to be used for actual execution.StringtoString()<T> Tvisit(ExpNodeVisitor<T> visitor)Visit the components of this query
-
-
-
Method Detail
-
select
public static SelectAdapter select(String... columns)
Factory to create a new instance of the builder needed to create this statement- Parameters:
columns-- Returns:
-
select
public static SelectAdapter select(boolean distinct, String... columns)
Factory to start building a SELECT DISTINCT statement- Parameters:
distinct-columns-- Returns:
-
addColumns
public void addColumns(String... columns)
Add the list of simple columns- Parameters:
columns-
-
addColumn
public void addColumn(String source, String name)
Add a single column to the select list- Parameters:
source-name-
-
addColumn
public void addColumn(String source, String name, Alias alias)
Add a single column to the select list, providing an alias for the column- Parameters:
source-name-alias-
-
addTable
public void addTable(String schemaName, String tableName)
Add a table item to the from-clause- Parameters:
schemaName-tableName-
-
addTable
public void addTable(String tableName, Alias alias)
Add a table item with an alias to the from-clause- Parameters:
tableName-alias-
-
addTable
public void addTable(String tableName)
Add a table item to the from-clause- Parameters:
tableName-
-
addTable
public void addTable(String schemaName, String tableName, Alias alias)
Add a schema-qualified table item with an alias to the from clause- Parameters:
schemaName-tableName-alias-
-
addFrom
public void addFrom(Select sub, Alias alias)
Add a sub-select statement with an alias to the from-clause- Parameters:
sub-alias-
-
setWhereClause
public void setWhereClause(WhereClause wc)
Set the where-clause for this statement- Parameters:
wc-
-
setGroupByClause
public void setGroupByClause(GroupByClause gb)
Set the group-by-clause for this statement- Parameters:
gb-
-
addHavingPredicate
public void addHavingPredicate(String predicate)
Add a predicate to the HAVING clause for this statement- Parameters:
predicate-
-
toDebugString
public String toDebugString()
A string representation of the query with the bind variables substituted in place which is handy for debugging - but not to be used for actual execution.- Returns:
- the query string
-
render
public <T> T render(StatementRenderer<T> renderer)
Render the components of the statement- Type Parameters:
T-- Parameters:
renderer-- Returns:
-
addInnerJoin
public void addInnerJoin(String tableName, Alias alias, ExpNode joinOnPredicate)
Add an inner join to the from clause for this select statement.- Parameters:
tableName-alias-joinOnPredicate-
-
addLeftOuterJoin
public void addLeftOuterJoin(String tableName, Alias alias, ExpNode joinOnPredicate)
Add a left outer join to the from clause for this select statement.- Parameters:
tableName-alias-joinOnPredicate-
-
setOrderByClause
public void setOrderByClause(OrderByClause ob)
- Parameters:
ob-
-
getWhereClause
public WhereClause getWhereClause()
Getter for the whereClause- Returns:
- the whereClause value, which can be null if not yet set
-
visit
public <T> T visit(ExpNodeVisitor<T> visitor)
Visit the components of this query- Type Parameters:
T-- Parameters:
visitor-- Returns:
-
addPagination
public void addPagination(int offset, int rowsPerPage)Add a pagination clause (offset/limit) to the query.- Parameters:
offset-rowsPerPage-
-
getOrderByClause
public OrderByClause getOrderByClause()
- Returns:
- the ORDER BY clause object for this select statement. Can be null.
-
-