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 void
addColumn(String source, String name)
Add a single column to the select listvoid
addColumn(String source, String name, Alias alias)
Add a single column to the select list, providing an alias for the columnvoid
addColumns(String... columns)
Add the list of simple columnsvoid
addFrom(Select sub, Alias alias)
Add a sub-select statement with an alias to the from-clausevoid
addHavingPredicate(String predicate)
Add a predicate to the HAVING clause for this statementvoid
addInnerJoin(String tableName, Alias alias, ExpNode joinOnPredicate)
Add an inner join to the from clause for this select statement.void
addLeftOuterJoin(String tableName, Alias alias, ExpNode joinOnPredicate)
Add a left outer join to the from clause for this select statement.void
addPagination(int offset, int rowsPerPage)
Add a pagination clause (offset/limit) to the query.void
addTable(String tableName)
Add a table item to the from-clausevoid
addTable(String tableName, Alias alias)
Add a table item with an alias to the from-clausevoid
addTable(String schemaName, String tableName)
Add a table item to the from-clausevoid
addTable(String schemaName, String tableName, Alias alias)
Add a schema-qualified table item with an alias to the from clauseOrderByClause
getOrderByClause()
WhereClause
getWhereClause()
Getter for the whereClause<T> T
render(StatementRenderer<T> renderer)
Render the components of the statementstatic SelectAdapter
select(boolean distinct, String... columns)
Factory to start building a SELECT DISTINCT statementstatic SelectAdapter
select(String... columns)
Factory to create a new instance of the builder needed to create this statementvoid
setGroupByClause(GroupByClause gb)
Set the group-by-clause for this statementvoid
setOrderByClause(OrderByClause ob)
void
setWhereClause(WhereClause wc)
Set the where-clause for this statementString
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.String
toString()
<T> T
visit(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.
-
-