public class CommonTableExpression extends SqlObject implements Verifiable<CommonTableExpression>
"WITH "
clause. Useable with queries which extend BaseCTEQuery
.
A CommonTableExpression creates a pseudo Table
and pseudo Column
s which can subsequently be used in the queries to which this
definition applies.
ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
Constructor and Description |
---|
CommonTableExpression(String name) |
Modifier and Type | Method and Description |
---|---|
Column |
addColumn(String name)
Adds a new column with the given name to this CTE and returns the
pseudo Column instane.
|
void |
appendTo(AppendableExt app)
Appends this object to the given AppendableExt.
|
protected void |
collectSchemaObjects(ValidationContext vContext)
Used during Query.validate() calls to collect the dbschema objects
referenced in a query.
|
Column |
findColumn(String name)
Returns a previously defined pseudo Column from this CTE definition with
the given name, or
null if one cannot be found. |
Table |
getTable()
Returns the pseudo Table instance for this CTE.
|
CommonTableExpression |
setQuery(Object query)
Sets the CTE definition query.
|
CommonTableExpression |
setTableAlias(String alias)
Sets the pseudo Table alias for use by the pseudo Columns when used in
subsequent queries.
|
CommonTableExpression |
validate()
Runs validation on this verifiable object.
|
void |
validate(ValidationContext vContext)
Runs validation on this verifiable object using a previously collected
ValidationContext.
|
collectSchemaObjects, doValidate, toString
toString, toString
public CommonTableExpression(String name)
name
- name of this common table expression.public Table getTable()
public Column addColumn(String name)
public Column findColumn(String name)
null
if one cannot be found.public CommonTableExpression setTableAlias(String alias)
Note, setting this is optional. If unset, a unique alias will be generated for this CTE when it is added to a BaseCTEQuery instance.
public CommonTableExpression setQuery(Object query)
Object
-> SqlObject
conversions handled by
Converter.toCustomSqlObject(Object)
.protected void collectSchemaObjects(ValidationContext vContext)
SqlObject
collectSchemaObjects
in class SqlObject
vContext
- handle to the current validation contextpublic void appendTo(AppendableExt app) throws IOException
Appendee
appendTo
in interface Appendee
appendTo
in class AppendeeObject
app
- the AppendableExt to which this class should append itselfIOException
- if the append failspublic final CommonTableExpression validate() throws ValidationException
Verifiable
validate
in interface Verifiable<CommonTableExpression>
ValidationException
public void validate(ValidationContext vContext) throws ValidationException
Verifiable
In general, this method will only be called internally, not by users.
validate
in interface Verifiable<CommonTableExpression>
vContext
- handle to the current, filled-in validation contextValidationException
Copyright © 2006–2021 OpenHMS. All rights reserved.