Package org.apache.empire.db
Class DBCommand
java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBCommandExpr
org.apache.empire.db.DBCommand
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
DBCommandHSql,DBCommandOracle,DBCommandPostgres,DBMSHandlerBase.DBMSCommand,DBMSHandlerH2.DBCommandH2,DBMSHandlerMSSQL.DBCommandMSSQL,DBMSHandlerMySQL.DBCommandMySQL,DBMSHandlerSQLite.DBCommandSQLite
This abstract class handles the creation of the SQL-Commands.
There are methods to create SQL-Commands, like update, insert,
delete and select.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.empire.db.DBCommandExpr
DBCommandExpr.DBCmdColumn, DBCommandExpr.DBCmdQuery -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected DBCmdParamListprotected List<DBColumnExpr>protected List<DBCompareExpr>protected List<DBJoinExpr>protected static final org.slf4j.Loggerprotected List<DBColumnExpr>protected booleanprotected List<DBCompareExpr>Fields inherited from class org.apache.empire.db.DBCommandExpr
cmdQuery, orderBy, SF_DEFAULT, SF_SKIP_FROM, SF_SKIP_GROUP, SF_SKIP_LIMIT, SF_SKIP_ORDER, SF_SKIP_SELECT, SF_SKIP_WHEREFields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESIS, CTX_VALUE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDBCommand(DBMSHandler dbms, boolean autoPrepareStmt) Constructs a new DBCommand object and set the specified DBDatabase object.protectedDBCommand(DBMSHandler dbms, boolean autoPrepareStmt, DBCmdParamList cmdParams) Constructs a new DBCommand object and set the specified DBDatabase object. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDeleteForTable(DBSQLBuilder sql, DBRowSet table) protected voidaddDeleteWithJoins(DBSQLBuilder sql, DBRowSet table) protected voidaddFrom(DBSQLBuilder sql) protected voidaddGrouping(DBSQLBuilder sql) voidaddJoins(List<DBJoinExpr> joinExprList) Adds a list of join expressions to the command.voidaddKeyConstraints(DBRowSet rowset, RecordData data) Adds key constraints the commandprotected voidaddOrder(DBSQLBuilder sql) final DBCmdParamaddParam()Adds an command parameter which will be used in a prepared statement.final DBCmdParamAdds an command parameter which will be used in a prepared statement.Adds an command parameter which will be used in a prepared statement.final DBCmdParamaddParam(DBColumnExpr colExpr, Object value) Adds an command parameter which will be used in a prepared statement.voidaddReferencedColumns(Set<DBColumn> list) Adds Columnsprotected voidaddSelect(DBSQLBuilder sql) protected voidaddUpdateForTable(DBSQLBuilder sql, DBRowSet table) protected voidaddUpdateWithJoins(DBSQLBuilder sql, DBRowSet table) protected final voidaddWhere(DBSQLBuilder sql) protected voidaddWhere(DBSQLBuilder sql, long context) voidaddWhereConstraints(List<DBCompareExpr> constraints) Adds a list of constraints to the command.protected voidappendCompareColExprs(DBRowSet table, DBCompareExpr expr, List<DBCompareColExpr> list) Appends all nested DBCompareColExpr for a particular RowSet to a listvoidclear()Clears the entire command object.voidClears the Group By clausevoidRemoves all constraints from the Having clausevoidClears the From / Join clausevoidClears the list of selected columns.voidClears the select distinct option.voidclearSet()Clears the Set clausevoidRemoves all constraints from the Where clauseclone()Creates a clone of this class.protected voidinternally used to remove unused Command Params from list Note: Only one thread my generate an SQL statementprotected DBSQLBuildercreateSQLBuilder(String initalSQL) creates a new DBSQLBuilderprotected DBCompareExprfindConstraintOn(List<DBCompareExpr> list, DBColumnExpr colExpr) finds a constraint on a particular column to the 'where' or 'having' collectionsfinal DBDatabaseReturns the database object to which this object belongs to.Returns the DataType selected by this command if only one column is returned If the command has more than one select expression DataType.UNKNOWN will be returnedfinal StringCreates a delete SQL-StatementReturns a copy of the defined where clauses.Returns a copy of the defined having clauses.Creates an insert SQL-StatementgetJoins()Returns a copy of the defined joins.Object[]Returns an array of parameter values for a prepared statement.Gets a list of all tables referenced by the query.voidgetSelect(DBSQLBuilder sql, int flags) Creates a select SQL-StatementReturns all select expressions as unmodifiable listReturns an array of all select expressionsReturns all set expressions as unmodifiable listfinal StringCreates an update SQL-StatementReturns a copy of the defined where clauses.final DBCommandgroupAll()Adds all select expressions which are not aggregates to the Group By clausefinal DBCommandgroupBy(Collection<? extends DBColumnExpr> columns) Adds a collection of columns to the Group By clause of an sql statement.groupBy(DBColumnExpr columnExpr) Adds a column expression to the Group By clause of an sql statement.final DBCommandgroupBy(DBColumnExpr... exprs) Adds a list of columns to the Group By clause of an sql statement.booleanChecks whether or not there are any aggregate functions in the SelectbooleanhasConstraintOn(DBRowSet rowset) Returns true if the command has a constraint on the given table or false otherwise.booleanReturns whether or not the command has group by setbooleanChecks whether the command has a constraint on a particular column expressionbooleanReturns true if the command has having-constraints or false if not.booleanReturns true if the command has a join on the given column or false otherwise.booleanReturns true if the command has a join on the given table or false otherwise.booleanreturns whether or not the command has any select expressionbooleanhasSelectExpr(DBColumnExpr expr) returns whether or not the command has a specific select expressionbooleanReturns whether or not the command has group by setprotected booleanhasSetExprOn(DBColumn column) Checks whether a column is in the list of set expressionsbooleanChecks whether the command has a constraint on a particular column expressionbooleanReturns true if the command has constraints or false if not.having(DBCompareExpr expr) adds a constraint to the having clause.final booleanprotected booleanreturns true if prepared statements are enabled for this commandbooleanReturns whether or not the select statement will be distinct or not.booleanisValid()Returns true if the this command has either Select or Set expressionsfinal DBCommandjoin(DBColumn[] left, DBColumn[] right, DBJoinType joinType, DBCompareExpr... addlConstraints) Multi-Column version of column based join expressionfinal DBCommandjoin(DBColumnExpr left, DBColumn right, DBJoinType joinType, DBCompareExpr... addlConstraints) Adds a join based on two columns to the list of join expressions.final DBCommandjoin(DBColumnExpr left, DBColumn right, DBCompareExpr... addlConstraints) Adds an inner join based on two columns to the list of join expressions.final DBCommandAdds a cross join for two tables or views New in release 3.1: Use left.on(right)) insteadfinal DBCommandjoin(DBRowSet rowset, DBCompareExpr cmp) Adds an inner join based on a compare expression to the command.final DBCommandjoin(DBRowSet rowset, DBCompareExpr cmp, DBJoinType joinType) Adds a join based on a compare expression to the command.join(DBJoinExpr join) Adds a join to the list of join expressions.final DBCommandjoin(DBJoinExpr join, DBJoinType joinType) Adds a join to the list of join expressions.final DBCommandjoinLeft(DBColumnExpr left, DBColumn right, DBCompareExpr... addlConstraints) Adds a left join based on two columns to the list of join expressions.final DBCommandjoinLeft(DBJoinExpr join) Adds a left join to the list of join expressions.final DBCommandjoinRight(DBColumnExpr left, DBColumn right, DBCompareExpr... addlConstraints) Adds a right join based on two columns to the list of join expressions.final DBCommandjoinRight(DBJoinExpr join) Adds a left join to the list of join expressions.limitRows(int limitRows) Overridden to change return type from DBCommandExpr to DBCommandorderBy(DBColumnExpr... exprs) Overridden to change return type from DBCommandExpr to DBCommandorderBy(DBColumnExpr expr, boolean desc) Overridden to change return type from DBCommandExpr to DBCommandorderBy(DBOrderByExpr... exprs) Overridden to change return type from DBCommandExpr to DBCommandorderByUpper(DBColumnExpr... expr) Overridden to change return type from DBCommandExpr to DBCommandorderByUpper(DBColumnExpr expr, boolean desc) Overridden to change return type from DBCommandExpr to DBCommandMakes sure all selected columns are identified by their proper names (qualified)protected voidinternally used to remove all command params used in a list of constraintsprotected voidremoveCommandParams(DBCompareExpr cmpExpr) internally used to remove the command param used in a constraintprotected booleanremoveConstraint(List<DBCompareExpr> list, DBCompareExpr cmpExpr) removes a constraint on a particular column to the 'where' or 'having' collectionsprotected DBCompareExprremoveConstraintOn(List<DBCompareExpr> list, DBColumnExpr colExpr) removes a constraint on a particular column to the 'where' or 'having' collectionsbooleanremoveHavingConstraint(DBCompareExpr cmpExpr) removes a constraint on a particular column from the where clauseremoves a constraint on a particular column from the having clausebooleanremoveJoinsOn(DBColumn column) removes all joins to a given columnbooleanremoveJoinsOn(DBRowSet rowset) removes all joins to a given table or viewvoidremoveSelect(DBColumnExpr... exprs) removes one or more expressions from the Select expression listbooleanremoveWhereConstraint(DBCompareExpr cmpExpr) removes a constraint on a particular column from the where clauseremoves a constraint on a particular column from the where clausevoidreplaceSelect(DBColumnExpr replExpr, DBColumnExpr replWith) replaces a select expression with another or removes a select expression In order to remove the expression, set the replWith parameter to null If the replace expression is not found, an ItemNotFoundException is thrownprotected voidinternally used to reset the command param usage count.final DBCommandselect(Collection<? extends DBColumnExpr> columns) Adds a collection of columns to the select phrase of an sql statement.select(DBColumnExpr expr) Adds a DBColumnExpr object to the Select collectionfinal DBCommandselect(DBColumnExpr... exprs) Adds a list of columns to the select phrase of an sql statement.Sets whether or not the select statement should contain the distinct directive .final DBCommandselectQualified(Collection<? extends DBColumnExpr> columns) Adds a collection of columns to the select phrase of an sql statement.selectQualified(DBColumnExpr... columns) Adds a list of columns with their qualified name to the select phrase of an sql statement.final DBCommandSelects all set expressions that have been set for this commandfinal DBCommandselectSetExpressions(List<DBSetExpr> setExprList) Selects all set expressions i.e. converts all calls like cmd.set(COL.to(VALUE)) into a select of the form cmd.select(VALUE.as(COL))Adds a single set expressions to this command Use column.to(...) to create a set expressionfinal DBCommandAdds a list of set expressions to this command Use column.to(...) to create a set expressionprotected voidsetConstraint(List<DBCompareExpr> list, DBCompareExpr expr) adds a constraint to the 'where' or 'having' collectionsvoidsetParentTables(DBRowSet... rowSets) Set parent tables for subquery command generation.skipRows(int skipRows) Overridden to change return type from DBCommandExpr to DBCommandprotected booleanuseCmdParam(DBColumnExpr col, Object value) returns true if a cmdParam should be used for the given column or false otherwisewhere(DBCompareExpr expr) Adds a constraint to the where phrase of the sql statement If another restriction already exists for the same column it will be replaced.final DBCommandwhere(DBCompareExpr... exprs) Adds a list of constraints to the where phrase of the sql statement If another restriction already exists for the same column it will be replaced.Methods inherited from class org.apache.empire.db.DBCommandExpr
addListExpr, addSQL, clearLimit, clearOrderBy, getCmdColumn, getDbms, getInsertInto, getInsertInto, getInsertInto, getOrderBy, getSelect, getSelect, hasOrderBy, intersect, not, notEmpty, result, union, unionAllMethods inherited from class org.apache.empire.db.DBObject
checkParamNull
-
Field Details
-
log
protected static final org.slf4j.Logger log -
selectDistinct
protected boolean selectDistinct -
select
-
set
-
joins
-
where
-
having
-
groupBy
-
parentTables
-
autoPrepareStmt
protected boolean autoPrepareStmt -
cmdParams
-
-
Constructor Details
-
DBCommand
Constructs a new DBCommand object and set the specified DBDatabase object.- Parameters:
dbms- the database handlerautoPrepareStmt- flag whether to automatically use literal values as prepared statement paramscmdParams- the command params list
-
DBCommand
Constructs a new DBCommand object and set the specified DBDatabase object.- Parameters:
dbms- the database handlerautoPrepareStmt- flag whether to automatically use literal values as prepared statement params
-
-
Method Details
-
createSQLBuilder
Description copied from class:DBCommandExprcreates a new DBSQLBuilder- Overrides:
createSQLBuilderin classDBCommandExpr- Parameters:
initalSQL- the initial sql fragment- Returns:
- the new DBSQLBuilder
-
isAutoPrepareStmt
public final boolean isAutoPrepareStmt()- Returns:
- true if auto Prepared Statements is activated for this record
-
clone
Creates a clone of this class.- Overrides:
clonein classDBCommandExpr
-
getDatabase
Description copied from class:DBObjectReturns the database object to which this object belongs to. For the database object itself this function will return the this pointer.- Specified by:
getDatabasein classDBObject- Returns:
- the database object
-
getParams
- Specified by:
getParamsin classDBCommandExpr
-
resetParamUsage
protected void resetParamUsage()internally used to reset the command param usage count. Note: Only one thread my generate an SQL statement -
completeParamUsage
protected void completeParamUsage()internally used to remove unused Command Params from list Note: Only one thread my generate an SQL statement -
removeCommandParams
internally used to remove the command param used in a constraint- Parameters:
cmpExpr- the compare expression
-
removeAllCommandParams
internally used to remove all command params used in a list of constraints- Parameters:
list- the list of compare expressions
-
setParentTables
Set parent tables for subquery command generation. Parent tables will be omitted to the FROM clause.- Parameters:
rowSets- the parent rowsets
-
isValid
public boolean isValid()Returns true if the this command has either Select or Set expressions- Specified by:
isValidin classDBCommandExpr
-
selectDistinct
Sets whether or not the select statement should contain the distinct directive .- Returns:
- itself (this)
-
isSelectDistinct
public boolean isSelectDistinct()Returns whether or not the select statement will be distinct or not.- Returns:
- true if the select will contain the distinct directive or false otherwise.
-
hasSelectExpr
public boolean hasSelectExpr()returns whether or not the command has any select expression- Specified by:
hasSelectExprin classDBCommandExpr- Returns:
- true if the command has any select expression of false otherwise
-
hasSelectExpr
returns whether or not the command has a specific select expression- Specified by:
hasSelectExprin classDBCommandExpr- Parameters:
expr- the column expr- Returns:
- true if the command contains the given select expression of false otherwise
-
getDataType
Description copied from class:DBCommandExprReturns the DataType selected by this command if only one column is returned If the command has more than one select expression DataType.UNKNOWN will be returned- Specified by:
getDataTypein classDBCommandExpr- Returns:
- the DataType of the selected expression or DataType.UNKNOWN
-
select
Adds a DBColumnExpr object to the Select collection- Parameters:
expr- the DBColumnExpr object- Returns:
- itself (this)
-
select
Adds a list of columns to the select phrase of an sql statement.- Parameters:
exprs- an vararg of DBColumnExpr's to select- Returns:
- itself (this)
-
select
Adds a collection of columns to the select phrase of an sql statement.- Parameters:
columns- the column expressions to add- Returns:
- itself (this)
-
selectSetExpressions
Selects all set expressions i.e. converts all calls like cmd.set(COL.to(VALUE)) into a select of the form cmd.select(VALUE.as(COL))- Parameters:
setExprList- the list of set expressions to select- Returns:
- itself (this)
-
selectSetExpressions
Selects all set expressions that have been set for this command- Returns:
- itself (this)
-
selectQualified
Adds a list of columns with their qualified name to the select phrase of an sql statement.- Parameters:
columns- one or more columns to select- Returns:
- itself (this)
-
selectQualified
Adds a collection of columns to the select phrase of an sql statement.- Parameters:
columns- the column expressions to add- Returns:
- itself (this)
-
qualifyAll
Makes sure all selected columns are identified by their proper names (qualified)- Returns:
- itself (this)
-
getSelectExprList
Returns an array of all select expressions- Specified by:
getSelectExprListin classDBCommandExpr- Returns:
- an array of all DBColumnExpr objects or
nullif there is nothing to select
-
getSelectExpressions
Returns all select expressions as unmodifiable list- Specified by:
getSelectExpressionsin classDBCommandExpr- Returns:
- the list of DBColumnExpr used for select
-
replaceSelect
replaces a select expression with another or removes a select expression In order to remove the expression, set the replWith parameter to null If the replace expression is not found, an ItemNotFoundException is thrown- Parameters:
replExpr- the expression to replacereplWith- the expression to replace with
-
removeSelect
removes one or more expressions from the Select expression list- Parameters:
exprs- the expression(s) to be removed
-
hasAggegation
public boolean hasAggegation()Checks whether or not there are any aggregate functions in the Select- Returns:
- true if at least on of the selected expressions is an aggregate
-
set
Adds a single set expressions to this command Use column.to(...) to create a set expression- Parameters:
expr- the DBSetExpr object(s)- Returns:
- itself (this)
-
set
Adds a list of set expressions to this command Use column.to(...) to create a set expression- Parameters:
exprs- the DBSetExpr object(s)- Returns:
- itself (this)
-
hasSetExpr
public boolean hasSetExpr()Returns whether or not the command has group by set- Returns:
- true if at least one set expression is present
-
hasSetExprOn
Checks whether a column is in the list of set expressions- Parameters:
column- the column to check- Returns:
trueif there is a set expression
-
getSetExpressions
Returns all set expressions as unmodifiable list- Returns:
- the list of DBSetExpr used for set
-
addParam
Adds an command parameter which will be used in a prepared statement. The command parameter returned may be used to alter the value.- Parameters:
type- the data type of the parametervalue- the initial parameter value- Returns:
- the command parameter object
-
addParam
Adds an command parameter which will be used in a prepared statement. The initial value of the command parameter is null but can be modified using the setValue method.- Parameters:
colExpr- the column expression for which to create the parametervalue- the initial parameter value- Returns:
- the command parameter object
-
addParam
Adds an command parameter which will be used in a prepared statement. The initial value of the command parameter is null but can be modified using the setValue method.- Parameters:
value- the initial value of the added param- Returns:
- the command parameter object
-
addParam
Adds an command parameter which will be used in a prepared statement. The initial value of the command parameter is null but can be modified using the setValue method.- Returns:
- the command parameter object
-
join
Adds a join to the list of join expressions.- Parameters:
join- the join expression- Returns:
- itself (this)
-
join
Adds a join to the list of join expressions.- Parameters:
join- the join expressionjoinType- the type of join- Returns:
- itself (this)
-
joinLeft
Adds a left join to the list of join expressions.- Parameters:
join- the join expression- Returns:
- itself (this)
-
joinRight
Adds a left join to the list of join expressions.- Parameters:
join- the join expression- Returns:
- itself (this)
-
join
Adds an inner join based on two columns to the list of join expressions. New in release 3.1: Use join(left.on(right).and(addlConstraint)) instead- Parameters:
left- the left join valueright- the right joinaddlConstraints- additional compare expressions- Returns:
- itself (this)
-
joinLeft
public final DBCommand joinLeft(DBColumnExpr left, DBColumn right, DBCompareExpr... addlConstraints) Adds a left join based on two columns to the list of join expressions. New in release 3.1: Use joinLeft(left.on(right).and(addlConstraint)) instead- Parameters:
left- the left join valueright- the right joinaddlConstraints- additional compare expressions- Returns:
- itself (this)
-
joinRight
public final DBCommand joinRight(DBColumnExpr left, DBColumn right, DBCompareExpr... addlConstraints) Adds a right join based on two columns to the list of join expressions. New in release 3.1: Use joinRight(left.on(right).and(addlConstraint)) instead- Parameters:
left- the left join valueright- the right joinaddlConstraints- additional compare expressions- Returns:
- itself (this)
-
join
public final DBCommand join(DBColumnExpr left, DBColumn right, DBJoinType joinType, DBCompareExpr... addlConstraints) Adds a join based on two columns to the list of join expressions. Migration hint from 2.x: replace ").where(" with just ","- Parameters:
left- the left join valueright- the right joinjoinType- type of join (DBJoinType.INNER,DBJoinType.LEFT,DBJoinType.RIGHT)addlConstraints- additional compare expressions- Returns:
- itself (this)
-
join
public final DBCommand join(DBColumn[] left, DBColumn[] right, DBJoinType joinType, DBCompareExpr... addlConstraints) Multi-Column version of column based join expression- Parameters:
left- the columsn on the leftright- the columns on the rightjoinType- the joinTypeaddlConstraints- additional compare expressions- Returns:
- itself (this)
-
join
Adds a cross join for two tables or views New in release 3.1: Use left.on(right)) instead- Parameters:
left- the left RowSetright- the right RowSet- Returns:
- itself (this)
-
join
Adds a join based on a compare expression to the command. New in release 3.1: Use joinLeft(rowset.on(cmp)) instead- Parameters:
rowset- table or view to joincmp- the compare expression with which to join the tablejoinType- type of join (DBJoinType.INNER,DBJoinType.LEFT,DBJoinType.RIGHT)- Returns:
- itself (this)
-
join
Adds an inner join based on a compare expression to the command. New in release 3.1: Use rowset.on(cmp) instead- Parameters:
rowset- table of view which to joincmp- the compare expression with wich to join the table- Returns:
- itself (this)
-
addJoins
Adds a list of join expressions to the command.- Parameters:
joinExprList- list of join expressions
-
getJoins
Returns a copy of the defined joins.- Returns:
- the list of joins
-
hasJoinOn
Returns true if the command has a join on the given table or false otherwise.- Parameters:
rowset- rowset table or view to join- Returns:
- true if the command has a join on the given table or false otherwise
-
hasJoinOn
Returns true if the command has a join on the given column or false otherwise.- Parameters:
column- the column to test- Returns:
- true if the command has a join on the given column or false otherwise
-
removeJoinsOn
removes all joins to a given table or view- Parameters:
rowset- the table or view for which to remove all joins- Returns:
- true if any joins have been removed or false otherwise
-
removeJoinsOn
removes all joins to a given column- Parameters:
column- the column for which to remove all joins- Returns:
- true if any joins have been removed or false otherwise
-
where
Adds a constraint to the where phrase of the sql statement If another restriction already exists for the same column it will be replaced.- Parameters:
expr- the DBCompareExpr object- Returns:
- itself (this)
-
where
Adds a list of constraints to the where phrase of the sql statement If another restriction already exists for the same column it will be replaced.- Parameters:
exprs- the DBCompareExpr object- Returns:
- itself (this)
-
hasWhereConstraints
public boolean hasWhereConstraints()Returns true if the command has constraints or false if not.- Returns:
- true if constraints have been set on the command
-
getWhereConstraints
Returns a copy of the defined where clauses.- Returns:
- vector of where clauses
-
removeWhereConstraint
removes a constraint on a particular column from the where clause- Parameters:
cmpExpr- the compare expression which to remove- Returns:
- true if the constraint was removed
-
removeWhereConstraintOn
removes a constraint on a particular column from the where clause- Parameters:
col- the column expression for which to remove the constraint- Returns:
- the constraint on the given column if present or null otherwise
-
hasWhereConstraintOn
Checks whether the command has a constraint on a particular column expression- Parameters:
col- the column expression which to check- Returns:
- true if a where constraint for the given column exists
-
addWhereConstraints
Adds a list of constraints to the command.- Parameters:
constraints- list of constraints
-
addKeyConstraints
Adds key constraints the command- Parameters:
rowset- the rowset for which to add constraintsdata- the record data from which to take the key values
-
having
adds a constraint to the having clause.- Parameters:
expr- the DBCompareExpr object- Returns:
- itself (this)
-
hasHavingConstraints
public boolean hasHavingConstraints()Returns true if the command has having-constraints or false if not.- Returns:
- true if constraints have been set on the command
-
getHavingConstraints
Returns a copy of the defined having clauses.- Returns:
- list of having constraints
-
removeHavingConstraint
removes a constraint on a particular column from the where clause- Parameters:
cmpExpr- the compare expression which to remove- Returns:
- true if the constraint was removed
-
removeHavingConstraintOn
removes a constraint on a particular column from the having clause- Parameters:
col- the column expression for which to remove the constraint- Returns:
- the constraint on the given column if present or null otherwise
-
hasHavingConstraintOn
Checks whether the command has a constraint on a particular column expression- Parameters:
col- the column expression which to check- Returns:
- true if a having constraint for the given column exists
-
hasConstraintOn
Returns true if the command has a constraint on the given table or false otherwise.- Parameters:
rowset- rowset table or view to join- Returns:
- true if the command has a join on the given table or false otherwise
-
hasGroupBy
public boolean hasGroupBy()Returns whether or not the command has group by set- Returns:
- true if a group by expression exists
-
getGroupBy
Returns a copy of the defined where clauses.- Returns:
- vector of where clauses
-
groupBy
Adds a column expression to the Group By clause of an sql statement.- Parameters:
columnExpr- the column expression- Returns:
- itself (this)
-
groupBy
Adds a list of columns to the Group By clause of an sql statement.- Parameters:
exprs- vararg of columns by which to group the rows- Returns:
- itself (this)
-
groupBy
Adds a collection of columns to the Group By clause of an sql statement.- Parameters:
columns- the column expressions to add- Returns:
- itself (this)
-
groupAll
Adds all select expressions which are not aggregates to the Group By clause- Returns:
- itself (this)
-
clearSelectDistinct
public void clearSelectDistinct()Clears the select distinct option. -
clearSelect
public void clearSelect()Clears the list of selected columns. -
clearSet
public void clearSet()Clears the Set clause -
clearJoin
public void clearJoin()Clears the From / Join clause -
clearWhere
public void clearWhere()Removes all constraints from the Where clause -
clearHaving
public void clearHaving()Removes all constraints from the Having clause -
clearGroupBy
public void clearGroupBy()Clears the Group By clause -
orderBy
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
orderByin classDBCommandExpr- Parameters:
exprs- vararg of orderBy expressions- Returns:
- itself (this)
- See Also:
-
orderBy
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
orderByin classDBCommandExpr- Parameters:
exprs- vararg of order by expressions- Returns:
- itself (this)
- See Also:
-
orderBy
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
orderByin classDBCommandExpr- Parameters:
expr- the expression for orderingdesc- if true, the results from select statement will sort top down- Returns:
- itself (this)
- See Also:
-
orderByUpper
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
orderByUpperin classDBCommandExpr- Parameters:
expr- the expression for orderingdesc- if true, the results from select statement will sort top down- Returns:
- itself (this)
- See Also:
-
orderByUpper
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
orderByUpperin classDBCommandExpr- Parameters:
expr- vararg of order by expressions- Returns:
- itself (this)
- See Also:
-
limitRows
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
limitRowsin classDBCommandExpr- Parameters:
limitRows- the number of rows to limit- Returns:
- itself (this)
-
skipRows
Overridden to change return type from DBCommandExpr to DBCommand- Overrides:
skipRowsin classDBCommandExpr- Parameters:
skipRows- the number of rows to skip- Returns:
- itself (this)
-
clear
public void clear()Clears the entire command object. -
isPreparedStatementsEnabled
protected boolean isPreparedStatementsEnabled()returns true if prepared statements are enabled for this command- Returns:
- true if prepared statements are enabled for this command
-
useCmdParam
returns true if a cmdParam should be used for the given column or false otherwise- Parameters:
col- the column expressionvalue- the parameter value- Returns:
- true if a cmdParam should be used for the given column
-
setConstraint
adds a constraint to the 'where' or 'having' collections- Parameters:
list- the 'where' or 'having' listexpr- the DBCompareExpr object
-
removeConstraint
removes a constraint on a particular column to the 'where' or 'having' collections- Parameters:
list- the 'where' or 'having' listcmpExpr- the compare expression which to remove- Returns:
- true if the constraint was removed
-
removeConstraintOn
removes a constraint on a particular column to the 'where' or 'having' collections- Parameters:
list- the 'where' or 'having' listcolExpr- the column expression for which to remove the constraint- Returns:
- the removed constraint
-
findConstraintOn
finds a constraint on a particular column to the 'where' or 'having' collections- Parameters:
list- the 'where' or 'having' listcolExpr- the column expression for which to remove the constraint- Returns:
- the constraint for the given column or null if not found
-
getRowSetList
Gets a list of all tables referenced by the query.- Returns:
- list of all rowsets (tables or views) used by the query
-
addReferencedColumns
Adds Columns- Specified by:
addReferencedColumnsin classDBExpr- Parameters:
list- list to which all used column expressions must be added
-
getParamValues
Returns an array of parameter values for a prepared statement. The parameters are supplied only after getSelect(), getUpdate(), getInsert() or getDelete() have been called- Specified by:
getParamValuesin classDBCommandExpr- Returns:
- an array of parameter values for a prepared statement
-
getSelect
Creates a select SQL-Statement- Specified by:
getSelectin classDBCommandExpr- Parameters:
sql- the sql builder to add the command toflags- bitwise context flags for sql building (see "Select Context Flags")
-
getInsert
Creates an insert SQL-Statement- Returns:
- an insert SQL-Statement
-
appendCompareColExprs
protected void appendCompareColExprs(DBRowSet table, DBCompareExpr expr, List<DBCompareColExpr> list) Appends all nested DBCompareColExpr for a particular RowSet to a list- Parameters:
table- the rowset for which to collect the DBCompareColExprexpr- a compare expressionlist- the list of compare expressions
-
getUpdate
Creates an update SQL-Statement- Returns:
- an update SQL-Statement
-
addUpdateForTable
-
addUpdateWithJoins
-
getDelete
Creates a delete SQL-Statement- Parameters:
table- the table object- Returns:
- a delete SQL-Statement
-
addDeleteForTable
-
addDeleteWithJoins
-
addSelect
-
addFrom
-
addWhere
-
addWhere
-
addGrouping
-
addOrder
-