|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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
|
Field Summary | |
---|---|
protected String |
alias
|
protected DBCommandExpr |
cmdExpr
|
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(DBCommandExpr cmd)
Creaes a DBQuery object from a given command object. |
|
DBQuery(DBCommandExpr cmd,
DBColumn keyColumn)
Constructs a new DBQuery object initialize the query object. |
|
DBQuery(DBCommandExpr 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(StringBuilder buf,
long context)
Adds the select SQL Command of this object to the specified StringBuilder object. |
void |
createRecord(DBRecord rec,
Connection conn)
Returns an error, because it is not possible to add a record to a query. |
void |
deleteRecord(Object[] keys,
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. |
String |
getAlias()
not applicable - returns null |
DBCommandExpr |
getCommandExpr()
returns the underlying command expression |
DBColumn[] |
getKeyColumns()
return query key columns |
String |
getName()
not applicable - returns null |
DBQuery.DBQueryColumn[] |
getQueryColumns()
Gets all columns of this rowset (e.g. |
Object[] |
getRecordKey(DBRecord record)
Returns a array of primary key columns by a specified DBRecord object. |
void |
initRecord(DBRecord rec,
Object[] keyValues,
boolean insert)
Initialize specified DBRecord object with primary key columns (the Object[] keyValues). |
boolean |
isUpdateable()
Returns whether or not the table supports record updates. |
void |
readRecord(DBRecord rec,
Object[] key,
Connection conn)
Creates a select SQL-Command of the query call the InitRecord method to execute the SQL-Command. |
void |
updateRecord(DBRecord rec,
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, equals, findById, getColumn, getColumn, getColumnIndex, getColumnIndex, getColumnReferences, getColumns, getComment, getDatabase, getFullName, getId, getRenameTablePhrase, getTimestampColumn, hashCode, 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 java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DBCommandExpr cmdExpr
protected DBColumn[] keyColumns
protected DBQuery.DBQueryColumn[] queryColumns
protected String alias
Constructor Detail |
---|
public DBQuery(DBCommandExpr cmd, DBColumn[] keyColumns)
cmd
- the SQL-CommandkeyColumns
- an array of the primary key columnspublic DBQuery(DBCommandExpr cmd, DBColumn keyColumn)
cmd
- the SQL-CommandkeyColumn
- the primary key columnpublic DBQuery(DBCommandExpr cmd)
cmd
- the command object representing an SQL-Command.Method Detail |
---|
public DBCommandExpr getCommandExpr()
public String getName()
getName
in class DBRowSet
public String getAlias()
getAlias
in class DBRowSet
public boolean isUpdateable()
isUpdateable
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 Object[] getRecordKey(DBRecord record)
getRecordKey
in class DBRowSet
record
- the DBRecord object, contains all fields and the field properties
public void addSQL(StringBuilder buf, long context)
addSQL
in class DBExpr
buf
- the SQL-Commandcontext
- the current SQL-Command contextpublic void initRecord(DBRecord rec, Object[] keyValues, boolean insert)
initRecord
in class DBRowSet
rec
- the Record objectkeyValues
- an array of the primary key columnspublic void createRecord(DBRecord rec, Connection conn)
createRecord
in class DBRowSet
rec
- the DBRecord object, contains all fields and the field propertiesconn
- a valid database connection
NotImplementedException
- because this is not implementedpublic void readRecord(DBRecord rec, Object[] key, Connection conn)
readRecord
in class DBRowSet
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 void updateRecord(DBRecord rec, 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 void deleteRecord(Object[] keys, 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 |