|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.commons.ErrorObject
org.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBCommandExpr
org.apache.empire.db.DBCommand
public abstract class DBCommand
This abstract class handles the creation of the SQL-Commands. There are methods to create SQL-Commandos, like update, insert, delete and select.
Nested Class Summary | |
---|---|
static class |
DBCommand.DBCmdParameter
|
Field Summary |
---|
Fields inherited from class org.apache.empire.db.DBExpr |
---|
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE |
Method Summary | |
---|---|
DBCommand.DBCmdParameter |
addCmdParam(java.lang.Object item)
Adds an object to in the list of Parameters and returns a parameter object. |
void |
addJoins(java.util.List<DBJoinExpr> joinExprList)
Adds a list of join expressions to the command. |
void |
addReferencedColumns(java.util.Set<DBColumn> list)
Adds Columns |
void |
addWhereConstraints(java.util.List<DBCompareExpr> constraints)
Adds a list of constraints to the command. |
void |
clear()
Clears the entire command object. |
void |
clearGroupBy()
Clears the list of group by constraints. |
void |
clearHaving()
Clears the list of having constraints. |
void |
clearJoin()
Clears the list of join expressions. |
void |
clearSelect()
Clears the list of selected columns. |
void |
clearSelectDistinct()
Clears the select distinct option. |
void |
clearSet()
Clears the list of set expressions. |
void |
clearWhere()
Clears the list of where constraints. |
DBCommand |
clone()
Creates a clone of this class. |
java.lang.Object[] |
getCmdParams()
Returns the list of parameter values for a prepared statement. |
DBDatabase |
getDatabase()
Returns the current DBDatabase object. |
java.lang.String |
getDelete(DBTable table)
Creates the delete SQL-Command. |
java.lang.String |
getInsert()
Creates the insert SQL-Command. |
java.util.List<DBJoinExpr> |
getJoins()
Returns a copy of the defined joins. |
boolean |
getSelect(java.lang.StringBuilder buf)
|
DBColumnExpr[] |
getSelectExprList()
Returns a array of all DBColumnExpr object of the Vector: 'select'. |
java.lang.String |
getUpdate()
Creates the update SQL-Command. |
java.util.List<DBCompareExpr> |
getWhereConstraints()
Returns a copy of the defined where clauses. |
void |
groupBy(DBColumnExpr expr)
Adds a column to the group by phrase of an sql statement. |
void |
groupBy(DBColumnExpr[] exprList)
Adds a list columns to the group by phrase of an sql statement. |
void |
groupBy(DBColumnExpr expr1,
DBColumnExpr expr2)
Adds two columns to the group by phrase of an sql statement. |
void |
groupBy(DBColumnExpr expr1,
DBColumnExpr expr2,
DBColumnExpr expr3)
Adds three columns to the group by phrase of an sql statement. |
boolean |
hasJoinOn(DBRowSet rowset)
Returns true if the command has a join on the given table or false otherwise. |
boolean |
hasSelectExpr()
Returns true if the command has constaints or false if not. |
boolean |
hasWhereConstraints()
Returns true if the command has constaints or false if not. |
void |
having(DBCompareExpr expr)
Sets a having contraint. |
boolean |
isSelectDistinct()
Returns whether or not the select statement will be distinct or not. |
boolean |
isValid()
|
boolean |
isValidQuery()
Returns whether the command object can produce a select sql-statement. |
boolean |
isValidUpdate()
Returns whether the command object can produce a update sql-statement. |
DBJoinExpr |
join(DBColumnExpr left,
DBColumn right)
Adds an inner join based on two columns to the list of join expressions. |
DBJoinExpr |
join(DBColumnExpr left,
DBColumn right,
DBJoinType joinType)
Adds a join based on two columns to the list of join expressions. |
void |
join(DBJoinExpr join)
Adds a join to the list of join expressions. |
DBJoinExpr |
join(DBRowSet rowset,
DBCompareExpr cmp)
Adds an inner join based on a compare expression to the command. |
DBJoinExpr |
join(DBRowSet rowset,
DBCompareExpr cmp,
DBJoinType joinType)
Adds a join based on a compare expression to the command. |
void |
select(java.util.Collection<DBColumnExpr> columns)
Adds a list of column expression to the select clause |
void |
select(DBColumnExpr expr)
Adds a DBColumnExpr object to the Vector: 'select'. |
void |
select(DBColumnExpr[] exprList)
This helper function adds an array of DBColumnExpr objects to list of select-columns. |
void |
select(DBColumnExpr expr1,
DBColumnExpr expr2)
This helper function adds two DBColumnExpr objects to the Vector: 'select' |
void |
select(DBColumnExpr expr1,
DBColumnExpr expr2,
DBColumnExpr expr3)
This helper function adds three DBColumnExpr objects to the Vector: 'select'. |
void |
select(DBColumnExpr expr1,
DBColumnExpr expr2,
DBColumnExpr expr3,
DBColumnExpr expr4)
This helper function adds four DBColumnExpr objects to the Vector: 'select'. |
void |
select(DBColumnExpr expr1,
DBColumnExpr expr2,
DBColumnExpr expr3,
DBColumnExpr expr4,
DBColumnExpr expr5)
This helper function adds five DBColumnExpr objects to the Vector: 'select'. |
void |
select(java.util.List<DBColumn> columns)
Adds a list of column expression to the select clause |
void |
selectDistinct()
Sets whether or not the select statement should contain the distinct directive . |
void |
set(DBSetExpr expr)
Inserts DBSetExpr objects to the Vector 'set'. |
boolean |
setCmdParam(int index,
java.lang.Object item)
Sets a object to in the list of Parameters. |
void |
where(DBCompareExpr expr)
Adds a compare expression to the list of constraints. |
Methods inherited from class org.apache.empire.db.DBCommandExpr |
---|
addSQL, clearOrderBy, getCmdColumn, getCmdColumn, getInsertInto, getInsertInto, getSelect, intersect, orderBy, orderBy, union |
Methods inherited from class org.apache.empire.db.DBExpr |
---|
getValueClass |
Methods inherited from class org.apache.empire.commons.ErrorObject |
---|
clearError, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, isExceptionsEnabled, setExceptionsEnabled |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public DBCommand clone()
clone
in class java.lang.Object
public DBDatabase getDatabase()
getDatabase
in class DBObject
public boolean isValid()
isValid
in class DBCommandExpr
public boolean isValidQuery()
public boolean isValidUpdate()
public void selectDistinct()
public boolean isSelectDistinct()
public void select(DBColumnExpr expr)
expr
- the DBColumnExpr objectpublic void select(DBColumnExpr expr1, DBColumnExpr expr2)
expr1
- the first DBColumnExpr objectexpr2
- the second DBColumnExpr objectpublic void select(DBColumnExpr expr1, DBColumnExpr expr2, DBColumnExpr expr3)
public void select(DBColumnExpr expr1, DBColumnExpr expr2, DBColumnExpr expr3, DBColumnExpr expr4)
public void select(DBColumnExpr expr1, DBColumnExpr expr2, DBColumnExpr expr3, DBColumnExpr expr4, DBColumnExpr expr5)
public void select(DBColumnExpr[] exprList)
public void select(java.util.Collection<DBColumnExpr> columns)
public void select(java.util.List<DBColumn> columns)
public void set(DBSetExpr expr)
expr
- the DBSetExpr object(s)public boolean setCmdParam(int index, java.lang.Object item)
public DBCommand.DBCmdParameter addCmdParam(java.lang.Object item)
public void join(DBJoinExpr join)
join
- the join expressionpublic DBJoinExpr join(DBColumnExpr left, DBColumn right, DBJoinType joinType)
left
- the left join valueright
- the right joinjoinType
- type of join (INNER, LEFT, RIGHT)public DBJoinExpr join(DBColumnExpr left, DBColumn right)
left
- the left join valueright
- the right joinpublic DBJoinExpr join(DBRowSet rowset, DBCompareExpr cmp, DBJoinType joinType)
rowset
- table of view which to joincmp
- the compare expression with wich to join the tablejoinType
- type of join (INNER, LEFT, RIGHT)public DBJoinExpr join(DBRowSet rowset, DBCompareExpr cmp)
rowset
- table of view which to joincmp
- the compare expression with wich to join the tablepublic void addJoins(java.util.List<DBJoinExpr> joinExprList)
joinExprList
- list of join expressionspublic boolean hasJoinOn(DBRowSet rowset)
public void where(DBCompareExpr expr)
expr
- the DBCompareExpr objectpublic boolean hasWhereConstraints()
public java.util.List<DBCompareExpr> getWhereConstraints()
public java.util.List<DBJoinExpr> getJoins()
public void addWhereConstraints(java.util.List<DBCompareExpr> constraints)
constraints
- list of constraintspublic void having(DBCompareExpr expr)
expr
- the DBCompareExpr objectpublic void groupBy(DBColumnExpr[] exprList)
exprList
- array of columns by which to group the rowspublic void groupBy(DBColumnExpr expr)
expr
- the DBCompareExpr objectpublic void groupBy(DBColumnExpr expr1, DBColumnExpr expr2)
public void groupBy(DBColumnExpr expr1, DBColumnExpr expr2, DBColumnExpr expr3)
public boolean hasSelectExpr()
public boolean getSelect(java.lang.StringBuilder buf)
getSelect
in class DBCommandExpr
public DBColumnExpr[] getSelectExprList()
getSelectExprList
in class DBCommandExpr
public void clearSelectDistinct()
public void clearSelect()
public void clearSet()
public void clearJoin()
public void clearWhere()
public void clearHaving()
public void clearGroupBy()
public void clear()
public void addReferencedColumns(java.util.Set<DBColumn> list)
addReferencedColumns
in class DBExpr
list
- list to which all used column expressions must be addedpublic java.lang.Object[] getCmdParams()
public java.lang.String getUpdate()
public java.lang.String getInsert()
public java.lang.String getDelete(DBTable table)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |