public class DBQuery extends DBRowSet
Modifier and Type | Class and Description |
---|---|
protected static class |
DBQuery.DBQueryExprColumn
DBQueryExprColumn
|
DBRowSet.FieldInitMode, DBRowSet.PartialMode
Modifier and Type | Field and Description |
---|---|
protected String |
alias |
protected DBCommandExpr |
cmdExpr |
protected DBColumn[] |
keyColumns |
protected DBQueryColumn[] |
queryColumns |
beanType, columnReferences, columns, comment, db, entityName, log, timestampColumn
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESIS, CTX_VALUE
Constructor and Description |
---|
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.
|
DBQuery(DBCommandExpr cmd,
DBColumn[] keyColumns,
String alias)
Constructor initializes the query object.
|
DBQuery(DBCommandExpr cmd,
DBColumn keyColumn,
String alias)
Constructs a new DBQuery object initialize the query object.
|
DBQuery(DBCommandExpr cmd,
String alias)
Creaes a DBQuery object from a given command object.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
addJoinRestriction(DBCommand cmd,
DBColumn updCol,
DBColumn joinCol,
DBColumn[] keyColumns,
Object[] key,
DBRecordBase record)
Adds join restrictions to the supplied command object.
|
void |
addSQL(DBSQLBuilder sql,
long context)
Adds the select SQL Command of this object to the specified StringBuilder object.
|
DBQueryColumn |
column(DBColumnExpr expr)
This is a convenience shortcut for findQueryColumn
|
DBQueryColumn |
column(String name)
This is a convenience shortcut for findQueryColumn
|
protected DBQueryColumn |
createQueryColumn(DBColumnExpr expr,
int index)
factory method for column expressions in order to allow overrides
|
void |
createRecord(DBRecordBase record,
Object[] initalKey,
boolean deferredInit)
Returns an error, because it is not possible to add a record to a query.
|
void |
deleteRecord(Object[] key,
DBContext context)
Deletes a record identified by its primary key from the database.
|
DBQueryColumn |
findColumn(DBColumnExpr expr)
This function provides the query column object for a particular query command expression
|
DBQueryColumn |
findColumn(String name)
This function provides the query column object for a particular query command expression
|
String |
getAlias()
not applicable - returns null
|
protected DBColumnExpr |
getColumnExprAt(int index)
Returns the column expression at a given column index
Allow overrides in derived classes
|
int |
getColumnIndex(ColumnExpr columnExpr)
Gets the index of a particular column expression.
|
int |
getColumnIndex(DBColumn column)
Gets the index of a particular column expression.
|
DBCommandExpr |
getCommandExpr()
returns the underlying command expression
|
protected DBCommand |
getCommandFromExpression()
returns the command from the underlying command expression or throws an exception
|
DBColumn[] |
getKeyColumns()
return query key columns
|
String |
getName()
not applicable - returns null
|
DBQueryColumn[] |
getQueryColumns()
Gets all columns of this rowset (e.g. for cmd.select()).
|
protected Object[] |
getRecordKey(DBRecordBase record)
Returns a array of primary key columns by a specified DBRecord object.
|
void |
initRecord(DBRecordBase record,
DBRecordData recData)
Add rowset data
|
boolean |
isUpdateable()
Returns whether or not the table supports record updates.
|
void |
readRecord(DBRecordBase record,
DBCompareExpr whereConstraints)
Creates a select SQL-Command of the query call the InitRecord method to execute the SQL-Command.
|
void |
updateRecord(DBRecordBase record)
Updates a query record by creating individual update commands for each table.
|
addColumnReference, addReferencedColumns, checkParamRecord, completeInitRecord, count, createRecordCommand, deleteAllReferences, deleteRecord, deleteReferenceRecords, equals, getBeanType, getColumn, getColumn, getColumnReferences, getColumns, getComment, getDatabase, getEntityName, getFullName, getIdentifier, getKeyConstraints, getRenameTablePhrase, getRowsetData, getTimestampColumn, hashCode, initRecord, initRecordDefaultValues, isColumnReadOnly, isKeyColumn, isSame, key, on, on, prepareInitRecord, readRecord, readRecord, recordExists, recordExists, setBeanType, setBeanType, setComment, setEntityName, setRowsetData, setTimestampColumn
checkParamNull
protected final DBCommandExpr cmdExpr
protected final DBColumn[] keyColumns
protected final DBQueryColumn[] queryColumns
protected final String alias
public DBQuery(DBCommandExpr cmd, DBColumn[] keyColumns, String alias)
cmd
- the SQL-CommandkeyColumns
- an array of the primary key columnsalias
- the query aliaspublic DBQuery(DBCommandExpr cmd, DBColumn[] keyColumns)
cmd
- the SQL-CommandkeyColumns
- an array of the primary key columnspublic DBQuery(DBCommandExpr cmd, DBColumn keyColumn, String alias)
cmd
- the SQL-CommandkeyColumn
- the primary key columnalias
- the query aliaspublic DBQuery(DBCommandExpr cmd, DBColumn keyColumn)
cmd
- the SQL-CommandkeyColumn
- the primary key columnpublic DBQuery(DBCommandExpr cmd, String alias)
cmd
- the command object representing an SQL-Command.alias
- the query aliaspublic DBQuery(DBCommandExpr cmd)
cmd
- the command object representing an SQL-Command.public DBCommandExpr getCommandExpr()
public String getName()
public String getAlias()
public boolean isUpdateable()
isUpdateable
in class DBRowSet
public DBQueryColumn[] getQueryColumns()
public DBQueryColumn findColumn(DBColumnExpr expr)
expr
- the DBColumnExpr objectpublic DBQueryColumn findColumn(String name)
name
- the column namepublic DBQueryColumn column(DBColumnExpr expr)
expr
- the DBColumnExpr objectpublic DBQueryColumn column(String name)
name
- the column namepublic DBColumn[] getKeyColumns()
getKeyColumns
in interface EntityType
getKeyColumns
in class DBRowSet
protected Object[] getRecordKey(DBRecordBase record)
record
- the DBRecord object, contains all fields and the field propertiespublic void addSQL(DBSQLBuilder sql, long context)
public void initRecord(DBRecordBase record, DBRecordData recData)
initRecord
in class DBRowSet
record
- the record objectrecData
- the record data from which to initialized the recordpublic void createRecord(DBRecordBase record, Object[] initalKey, boolean deferredInit)
createRecord
in class DBRowSet
record
- the DBRecord object, contains all fields and the field propertiesinitalKey
- the initial record keydeferredInit
- flag whether to defer record initializationNotImplementedException
- because this is not implementedpublic void readRecord(DBRecordBase record, DBCompareExpr whereConstraints)
readRecord
in class DBRowSet
record
- the DBRecord object, contains all fields and the field propertieswhereConstraints
- the constraint for querying the recordpublic void updateRecord(DBRecordBase record)
updateRecord
in class DBRowSet
record
- the DBRecord object. contains all fields and the field propertiespublic void deleteRecord(Object[] key, DBContext context)
deleteRecord
in class DBRowSet
key
- array of primary key valuescontext
- the database contextprotected boolean addJoinRestriction(DBCommand cmd, DBColumn updCol, DBColumn joinCol, DBColumn[] keyColumns, Object[] key, DBRecordBase record)
cmd
- the commandupdCol
- the update columnjoinCol
- the join columnkeyColumns
- the key columnskey
- the record keyrecord
- the recordprotected DBCommand getCommandFromExpression()
protected DBQueryColumn createQueryColumn(DBColumnExpr expr, int index)
expr
- public int getColumnIndex(ColumnExpr columnExpr)
getColumnIndex
in class DBRowSet
columnExpr
- the column expression for which to get the index ofpublic int getColumnIndex(DBColumn column)
DBRowSet
getColumnIndex
in class DBRowSet
column
- column the DBColumn to get the index forprotected DBColumnExpr getColumnExprAt(int index)
DBRowSet
getColumnExprAt
in class DBRowSet
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.