|
||||||||||
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.DBRowSet
org.apache.empire.db.DBQuery
public class DBQuery
This class can be used to wrap a query from a DBCommand and use it like a DBRowSet.
You may use this class for two purposes:
Nested Class Summary | |
---|---|
static class |
DBQuery.DBQueryColumn
|
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject |
---|
ErrorObject.ObjectErrorInfo |
Field Summary | |
---|---|
protected java.lang.String |
alias
|
protected DBCommand |
cmd
|
protected DBColumn[] |
keyColumns
|
protected DBQuery.DBQueryColumn[] |
queryColumns
|
Fields inherited from class org.apache.empire.db.DBRowSet |
---|
columnReferences, columns, comment, db, log, primaryKey, timestampColumn |
Fields inherited from class org.apache.empire.db.DBExpr |
---|
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE |
Constructor Summary | |
---|---|
DBQuery(DBCommand cmd)
Creaes a DBQuery object from a given command object. |
|
DBQuery(DBCommand cmd,
DBColumn keyColumn)
Constructs a new DBQuery object initialize the query object. |
|
DBQuery(DBCommand cmd,
DBColumn[] keyColumns)
Constructor initializes the query object. |
Method Summary | |
---|---|
protected boolean |
addJoinRestriction(DBCommand upd,
DBColumn updCol,
DBColumn keyCol,
DBColumn[] keyColumns,
DBRecord rec)
Adds join restrictions to the supplied command object. |
void |
addSQL(java.lang.StringBuilder buf,
long context)
Adds the select SQL Command of this object to the specified StringBuilder object. |
boolean |
createRecord(DBRecord rec,
java.sql.Connection conn)
Returns an error, because querys could't add new records to the database. |
boolean |
deleteRecord(java.lang.Object[] keys,
java.sql.Connection conn)
Deletes a record identified by its primary key from the database. |
DBQuery.DBQueryColumn |
findQueryColumn(DBColumnExpr expr)
This function searchs for equal columns given by the specified DBColumnExpr object. |
java.lang.String |
getAlias()
not applicable - returns null |
DBColumn[] |
getKeyColumns()
return query key columns |
java.lang.String |
getName()
not applicable - returns null |
DBQuery.DBQueryColumn[] |
getQueryColumns()
Gets all columns of this rowset (e.g. |
java.lang.Object[] |
getRecordKey(DBRecord record)
Returns a array of primary key columns by a specified DBRecord object. |
boolean |
initRecord(DBRecord rec,
java.lang.Object[] keyValues)
Initialize specified DBRecord object with primary key columns (the Object[] keyValues). |
boolean |
readRecord(DBRecord rec,
java.lang.Object[] key,
java.sql.Connection conn)
Creates a select SQL-Command of the query call the InitRecord method to execute the SQL-Command. |
boolean |
updateRecord(DBRecord rec,
java.sql.Connection conn)
Updates a query record by creating individual update commands for each table. |
Methods inherited from class org.apache.empire.db.DBRowSet |
---|
addColumnReference, addReferencedColumns, completeInitRecord, count, deleteAllReferences, deleteRecord, deleteReferenceRecords, getColumn, getColumn, getColumnIndex, getColumnIndex, getColumnReferences, getColumns, getComment, getDatabase, getFullName, getRenameTablePhrase, getTimestampColumn, initRecord, isColumnReadOnly, isKeyColumn, prepareInitRecord, readRecord, recordExists, recordExists, setComment, setKeyConstraints, setTimestampColumn |
Methods inherited from class org.apache.empire.db.DBExpr |
---|
getObjectValue, getValueClass |
Methods inherited from class org.apache.empire.db.DBObject |
---|
error, error |
Methods inherited from class org.apache.empire.commons.ErrorObject |
---|
clearError, clearErrorInfo, error, error, error, error, error, getErrorInfo, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, internalSetError, isExceptionsEnabled, setExceptionsEnabled, success |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DBCommand cmd
protected DBColumn[] keyColumns
protected DBQuery.DBQueryColumn[] queryColumns
protected java.lang.String alias
Constructor Detail |
---|
public DBQuery(DBCommand cmd, DBColumn[] keyColumns)
cmd
- the SQL-CommandkeyColumns
- an array of the primary key columnspublic DBQuery(DBCommand cmd, DBColumn keyColumn)
cmd
- the SQL-CommandkeyColumn
- the primary key columnpublic DBQuery(DBCommand cmd)
cmd
- the command object representing an SQL-Command.Method Detail |
---|
public java.lang.String getName()
getName
in class DBRowSet
public java.lang.String getAlias()
getAlias
in class DBRowSet
public DBQuery.DBQueryColumn[] getQueryColumns()
public DBQuery.DBQueryColumn findQueryColumn(DBColumnExpr expr)
expr
- the DBColumnExpr object
public DBColumn[] getKeyColumns()
getKeyColumns
in class DBRowSet
public java.lang.Object[] getRecordKey(DBRecord record)
getRecordKey
in class DBRowSet
record
- the DBRecord object, contains all fields and the field properties
public void addSQL(java.lang.StringBuilder buf, long context)
addSQL
in class DBExpr
buf
- the SQL-Commandcontext
- the current SQL-Command contextpublic boolean initRecord(DBRecord rec, java.lang.Object[] keyValues)
initRecord
in class DBRowSet
rec
- the Record objectkeyValues
- an array of the primary key columns
public boolean createRecord(DBRecord rec, java.sql.Connection conn)
createRecord
in class DBRowSet
rec
- the DBRecord object, contains all fields and the field propertiesconn
- a valid database connection
public boolean readRecord(DBRecord rec, java.lang.Object[] key, java.sql.Connection conn)
readRecord
in class DBRowSet
rec
- rec the DBRecord object, contains all fields and the field propertieskey
- an array of the primary key columnsconn
- a valid connection to the database.
public boolean updateRecord(DBRecord rec, java.sql.Connection conn)
updateRecord
in class DBRowSet
rec
- the DBRecord object. contains all fields and the field propertiesconn
- a valid connection to the database.
protected boolean addJoinRestriction(DBCommand upd, DBColumn updCol, DBColumn keyCol, DBColumn[] keyColumns, DBRecord rec)
public boolean deleteRecord(java.lang.Object[] keys, java.sql.Connection conn)
deleteRecord
in class DBRowSet
keys
- array of primary key valuesconn
- a valid database connection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |