Class Select
- java.lang.Object
 - 
- org.linuxforhealth.fhir.database.utils.query.Select
 
 
- 
public class Select extends java.lang.ObjectRepresentation of a select statement built bySelectAdapter.build() 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumn(java.lang.String source, java.lang.String name)Add a single column to the select listvoidaddColumn(java.lang.String source, java.lang.String name, Alias alias)Add a single column to the select list, providing an alias for the columnvoidaddColumn(java.lang.String columnValue, Alias alias)Add a value column to the select list, for example: addColumn("5", alias("RESOURCE_TYPE_ID")) can be used for: SELECT foo, 5 AS RESOURCE_TYPE_ID FROM ...voidaddColumns(java.lang.String... columns)Add the list of simple columnsvoidaddFrom(Select sub, Alias alias)Add a sub-select statement with an alias to the from-clausevoidaddHavingPredicate(java.lang.String predicate)Add a predicate to the HAVING clause for this statementvoidaddInnerJoin(java.lang.String tableName, Alias alias, ExpNode joinOnPredicate)Add an inner join to the from clause for this select statement.voidaddInnerJoin(Select sub, Alias alias, ExpNode joinOnPredicate)Add an inner join to the from clause for this select statement where the joining row source is a sub-queryvoidaddLeftOuterJoin(java.lang.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(java.lang.String tableName)Add a table item to the from-clausevoidaddTable(java.lang.String schemaName, java.lang.String tableName)Add a table item to the from-clausevoidaddTable(java.lang.String schemaName, java.lang.String tableName, Alias alias)Add a schema-qualified table item with an alias to the from clausevoidaddTable(java.lang.String tableName, Alias alias)Add a table item with an alias to the from-clausevoidaddWithClause(Select selectClause, Alias alias)Add a new WITH clause to the select statement for example WITH alias AS (SELECT ...) SELECT ...OrderByClausegetOrderByClause()WhereClausegetWhereClause()Getter for the whereClause<T> Trender(StatementRenderer<T> renderer)Render the components of the statementstatic SelectAdapterselect(boolean distinct, java.lang.String... columns)Factory to start building a SELECT DISTINCT statementstatic SelectAdapterselect(java.lang.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)voidsetUnion(Select union)Set a select to UNION with this query.voidsetUnionAll(Select unionAll)Set a select to UNION ALL with this query.voidsetWhereClause(WhereClause wc)Set the where-clause for this statementjava.lang.StringtoDebugString()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.java.lang.StringtoString()<T> Tvisit(ExpNodeVisitor<T> visitor)Visit the components of this query 
 - 
 
- 
- 
Method Detail
- 
select
public static SelectAdapter select(java.lang.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, java.lang.String... columns)
Factory to start building a SELECT DISTINCT statement- Parameters:
 distinct-columns-- Returns:
 
 
- 
addColumns
public void addColumns(java.lang.String... columns)
Add the list of simple columns- Parameters:
 columns-
 
- 
addWithClause
public void addWithClause(Select selectClause, Alias alias)
Add a new WITH clause to the select statement for example WITH alias AS (SELECT ...) SELECT ... FROM abc JOIN alias ON ...- Parameters:
 selectClause-alias-
 
- 
addColumn
public void addColumn(java.lang.String source, java.lang.String name)Add a single column to the select list- Parameters:
 source-name-
 
- 
addColumn
public void addColumn(java.lang.String source, java.lang.String name, Alias alias)Add a single column to the select list, providing an alias for the column- Parameters:
 source-name-alias-
 
- 
addColumn
public void addColumn(java.lang.String columnValue, Alias alias)Add a value column to the select list, for example: addColumn("5", alias("RESOURCE_TYPE_ID")) can be used for: SELECT foo, 5 AS RESOURCE_TYPE_ID FROM ...- Parameters:
 columnValue-alias-
 
- 
addTable
public void addTable(java.lang.String schemaName, java.lang.String tableName)Add a table item to the from-clause- Parameters:
 schemaName-tableName-
 
- 
addTable
public void addTable(java.lang.String tableName, Alias alias)Add a table item with an alias to the from-clause- Parameters:
 tableName-alias-
 
- 
addTable
public void addTable(java.lang.String tableName)
Add a table item to the from-clause- Parameters:
 tableName-
 
- 
addTable
public void addTable(java.lang.String schemaName, java.lang.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(java.lang.String predicate)
Add a predicate to the HAVING clause for this statement- Parameters:
 predicate-
 
- 
toString
public java.lang.String toString()
- Overrides:
 toStringin classjava.lang.Object
 
- 
toDebugString
public java.lang.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(java.lang.String tableName, Alias alias, ExpNode joinOnPredicate)Add an inner join to the from clause for this select statement.- Parameters:
 tableName-alias-joinOnPredicate-
 
- 
addInnerJoin
public void addInnerJoin(Select sub, Alias alias, ExpNode joinOnPredicate)
Add an inner join to the from clause for this select statement where the joining row source is a sub-query- Parameters:
 sub-alias-joinOnPredicate-
 
- 
addLeftOuterJoin
public void addLeftOuterJoin(java.lang.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.
 
 
- 
setUnion
public void setUnion(Select union)
Set a select to UNION with this query. 
- 
setUnionAll
public void setUnionAll(Select unionAll)
Set a select to UNION ALL with this query. 
 - 
 
 -