Class QueryColumn<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>
- java.lang.Object
-
- nz.co.gregs.dbvolution.expressions.AnyExpression<B,R,D>
-
- nz.co.gregs.dbvolution.columns.QueryColumn<B,R,D>
-
- Type Parameters:
B- the base Java type of this expression, e.g. IntegerR- the Results type of this expression, e.g. IntegerExpressionD- the QDT of this expression, e.g. DBInteger
- All Implemented Interfaces:
java.io.Serializable,ColumnProvider,DBExpression,ExpressionColumn<D>,HasSQLString,AnyResult<B>,ExpressionCanHaveNullValues
public class QueryColumn<B,R extends AnyResult<B>,D extends QueryableDatatype<B>> extends AnyExpression<B,R,D> implements ColumnProvider
Represents a database column storing a boolean value.This class adds the necessary methods to use a boolean column like a boolean expression.
Internally the class uses an AbsractColumn to store the column and overrides methods in BooleanExpression to insert the column into the expression.
Generally you get a BooleanColumn using
RowDefinition.column(DBBoolean).Support DBvolution at Patreon
- Author:
- Gregory Graham
- See Also:
RowDefinition,AbstractColumn,BooleanExpression, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class nz.co.gregs.dbvolution.expressions.AnyExpression
AnyExpression.CountAllExpression, AnyExpression.CountExpression, AnyExpression.NTileExpression, AnyExpression.PercentageExpression, AnyExpression.RankExpression
-
-
Constructor Summary
Constructors Constructor Description QueryColumn(DBQuery query, D field)Create a QueryColumn for the supplied field of the supplied query
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DasExpressionColumn()Creates a QueryableDatatype version of the expression suitable for use as a column.QueryColumn<B,R,D>copy()A Complete Copy Of This DBValue.Rexpression(B value)Rexpression(D value)Rexpression(R value)AbstractQueryColumngetColumn()Returns the AbstractColumn from this ColumnProvider.DgetQueryableDatatypeForExpressionValue()Provides a blank instance of theQueryableDatatypeused by this expression.SortProvidergetSortProvider()Provides the sorting for this column as defined by the methodsQueryableDatatype.setSortOrder(java.lang.Boolean),QueryableDatatype.setSortOrderAscending(), andQueryableDatatype.setSortOrderDescending()on the QDT.java.util.Set<DBRow>getTablesInvolved()Returns a Set of the DBRow instances involved in this expression.booleanisAggregator()Returns TRUE if this expression is an Aggregator like SUM() or LEAST().booleanisPurelyFunctional()Indicates whether or not the expression includes table columns.voidsetUseTableAlias(boolean useTableAlias)Indicates whether the ColumnProvider should use the table alias during query creation.java.lang.StringtoSQLString(DBDefinition db)Produces the snippet provided by this class.-
Methods inherited from class nz.co.gregs.dbvolution.expressions.AnyExpression
ascending, count, countAll, createSQLForFromClause, createSQLForGroupByClause, denseRank, descending, getIncludesNull, getInnerResult, highestFirst, highestLast, isComplexExpression, isNullSafetyTerminator, isWindowingFunction, lowestFirst, lowestLast, nTile, nTile, nTile, nullBoolean, nullDate, nullDateRepeat, nullExpression, nullInstant, nullInteger, nullLine2D, nullLineSegment2D, nullLocalDate, nullLocalDateTime, nullMultiPoint2D, nullNumber, nullPoint2D, nullPolygon2D, nullString, percentageRank, rank, rowNumber, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value
-
Methods inherited from interface nz.co.gregs.dbvolution.columns.ColumnProvider
ascending, descending
-
Methods inherited from interface nz.co.gregs.dbvolution.expressions.DBExpression
createSQLForFromClause, createSQLForGroupByClause, isComplexExpression, isWindowingFunction
-
Methods inherited from interface nz.co.gregs.dbvolution.expressions.ExpressionColumn
toExpressionColumn
-
-
-
-
Method Detail
-
toSQLString
public java.lang.String toSQLString(DBDefinition db)
Description copied from interface:HasSQLStringProduces the snippet provided by this class.This is only used internally.
If you are extending DBvolution and adding a new function this is the place to format the information for use in SQL. A DBDefinition instance is provided to supply context and so your SQL can used on multiple database engines.
- Specified by:
toSQLStringin interfaceHasSQLString- Overrides:
toSQLStringin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>- Parameters:
db- the target databaseSupport DBvolution at Patreon
- Returns:
- the DBValue formatted as a SQL snippet
-
copy
public QueryColumn<B,R,D> copy()
Description copied from interface:DBExpressionA Complete Copy Of This DBValue.Immutability in DBvolution is maintain by internally copying objects.
This method enables immutability by performing a deep copy of the object.
Singletons may return themselves but all other objects must return a new instance with copies of all mutable fields.
Support DBvolution at Patreon
- Specified by:
copyin interfaceDBExpression- Specified by:
copyin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>- Returns:
- a copy of this
DBValue
-
getColumn
public AbstractQueryColumn getColumn()
Description copied from interface:ColumnProviderReturns the AbstractColumn from this ColumnProvider.Support DBvolution at Patreon
- Specified by:
getColumnin interfaceColumnProvider- Returns:
- the column that this provider supplies.
-
getTablesInvolved
public java.util.Set<DBRow> getTablesInvolved()
Description copied from interface:DBExpressionReturns a Set of the DBRow instances involved in this expression.Used by QueryGraph to plot the connections between tables and avoid cartesian joins.
Support DBvolution at Patreon
- Specified by:
getTablesInvolvedin interfaceDBExpression- Overrides:
getTablesInvolvedin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>- Returns:
- a set of DBRow instances involved in this DBExpression.
-
setUseTableAlias
public void setUseTableAlias(boolean useTableAlias)
Description copied from interface:ColumnProviderIndicates whether the ColumnProvider should use the table alias during query creation.the standard implementation is
this.column.setUseTableAlias(useTableAlias);and passes the boolean along to the underlying AbstractColumn- Specified by:
setUseTableAliasin interfaceColumnProvider- Parameters:
useTableAlias- true or false
-
isPurelyFunctional
public boolean isPurelyFunctional()
Description copied from interface:DBExpressionIndicates whether or not the expression includes table columns.Purely functional expressions use only in-built functions or literal values to produce results and do not require data from tables.
Some databases, notably MS SQLServer, can not group purely functional expressions.
Support DBvolution at Patreon
- Specified by:
isPurelyFunctionalin interfaceDBExpression- Overrides:
isPurelyFunctionalin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>- Returns:
- TRUE if the expression does not access table data, otherwise FALSE.
-
isAggregator
public boolean isAggregator()
Description copied from interface:DBExpressionReturns TRUE if this expression is an Aggregator like SUM() or LEAST().Subclasses must implement this method returning TRUE if the expression will combine the results of several rows to produce a result. If the expression relies on subexpressions, then the isAggregator method must return TRUE if the subexpressions include an aggregator.
Aggregators collect several rows together to produce a single result. Examples are MAX, MIN, and AVERAGE.
They are only appropriate in the SELECT clause and generally require the GROUP BY clause to be useful.
Aggregators are used with
DBReport. Aggregator expressions are included in the SELECT clause but excluded from the GROUP BY clause.Support DBvolution at Patreon
- Specified by:
isAggregatorin interfaceDBExpression- Overrides:
isAggregatorin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>- Returns:
- TRUE if this DBExpression represents an aggregating functions
-
expression
public R expression(B value)
- Specified by:
expressionin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>
-
expression
public R expression(R value)
- Specified by:
expressionin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>
-
expression
public R expression(D value)
- Specified by:
expressionin classAnyExpression<B,R extends AnyResult<B>,D extends QueryableDatatype<B>>
-
asExpressionColumn
public D asExpressionColumn()
Description copied from interface:ExpressionColumnCreates a QueryableDatatype version of the expression suitable for use as a column.For example:
@DBColumn public DBString title = person.column(person.fullname).substringBefore(" ").asExpressionColumn();Support DBvolution at Patreon
- Specified by:
asExpressionColumnin interfaceExpressionColumn<B>- Returns:
- a QDT version of the expression
-
getQueryableDatatypeForExpressionValue
public D getQueryableDatatypeForExpressionValue()
Description copied from interface:DBExpressionProvides a blank instance of theQueryableDatatypeused by this expression.You are probably looking for
ExpressionColumn.asExpressionColumn().Note that this method is not good for use in everyday DBvolution code and should probably be reserved for meta-programming.
Support DBvolution at Patreon
- Specified by:
getQueryableDatatypeForExpressionValuein interfaceDBExpression- Returns:
- the QueryableDatatype subclass that corresponds to the results of this expression
-
getSortProvider
public SortProvider getSortProvider()
Description copied from interface:ColumnProviderProvides the sorting for this column as defined by the methodsQueryableDatatype.setSortOrder(java.lang.Boolean),QueryableDatatype.setSortOrderAscending(), andQueryableDatatype.setSortOrderDescending()on the QDT.At the time of querying the sort order defined on the original QDT field provided is add to the query, with ASCENDING being used as the default ordering.
To be certain of the ordering use the
AnyExpression.ascending()andAnyExpression.descending()methods.- Specified by:
getSortProviderin interfaceColumnProvider- Returns:
- a SortProvider configured to use the sorting defined on original QDT or ASCENDING.
-
-