|
||||||||||
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
public abstract class DBRowSet
This class is the base class for all the DBTable, DBView and DBQuery classes this class contains all the columns of the tables, views or queries
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject |
---|
ErrorObject.ObjectErrorInfo |
Field Summary | |
---|---|
protected java.util.Map<DBColumn,DBColumn> |
columnReferences
|
protected java.util.List<DBColumn> |
columns
|
protected java.lang.String |
comment
|
protected DBDatabase |
db
|
protected static org.slf4j.Logger |
log
|
protected DBIndex |
primaryKey
|
protected DBColumn |
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 | |
---|---|
DBRowSet(DBDatabase db)
Constructs a DBRecord object set the current database object. |
Method Summary | |
---|---|
protected boolean |
addColumnReference(DBColumn source,
DBColumn target)
Adds a column reference to the ist of table references. |
void |
addReferencedColumns(java.util.Set<DBColumn> list)
Internal function to obtain all DBColumnExpr-objects used by this expression. |
protected boolean |
completeInitRecord(DBRecord rec)
Completes the record initialisation. Override this function to do post initialisation processing. |
DBColumnExpr |
count()
Returns a new DBCountExpr object. |
abstract boolean |
createRecord(DBRecord rec,
java.sql.Connection conn)
|
protected boolean |
deleteAllReferences(java.lang.Object[] key,
java.sql.Connection conn)
Deletes all records which reference this table. |
abstract boolean |
deleteRecord(java.lang.Object[] keys,
java.sql.Connection conn)
|
boolean |
deleteRecord(java.lang.Object id,
java.sql.Connection conn)
Deletes a single record from the database. |
protected boolean |
deleteReferenceRecords(DBRelation.DBReference[] refs,
java.lang.Object[] parentKey,
java.sql.Connection conn)
Deletes all records which are referenced by a particular relation. |
abstract java.lang.String |
getAlias()
|
DBColumn |
getColumn(int iColumn)
Returns a DBColumn object by a specified index value. |
DBColumn |
getColumn(java.lang.String name)
Gets the column Expression with a particular name. |
int |
getColumnIndex(Column column)
Gets the index of a particular column expression. |
int |
getColumnIndex(DBColumn column)
Gets the index of a particular column expression. |
java.util.Map<DBColumn,DBColumn> |
getColumnReferences()
Returns the a list of column references. |
java.util.List<DBColumn> |
getColumns()
Gets all columns of this rowset (e.g. |
java.lang.String |
getComment()
|
DBDatabase |
getDatabase()
Returns the current DBDatabase object. |
java.lang.String |
getFullName()
Returns the full qualified name of the rowset. |
DBColumn[] |
getKeyColumns()
Returns an array of all primary key columns. |
abstract java.lang.String |
getName()
|
java.lang.Object[] |
getRecordKey(DBRecord rec)
Returns a array of primary key columns by a specified DBRecord object. |
protected java.lang.String |
getRenameTablePhrase()
Returns the sql phrase for renaming tables. |
DBColumn |
getTimestampColumn()
|
boolean |
initRecord(DBRecord rec,
DBRecordData recData)
Initializes a DBRecord for this rowset using the record data provided (i.e. |
boolean |
initRecord(DBRecord rec,
java.lang.Object[] keyValues)
Initializes a DBRecord for this RowSet and sets primary key values (the Object[] keyValues). |
boolean |
isColumnReadOnly(DBColumn col)
Checks whether a column is read only or writable. |
boolean |
isKeyColumn(DBColumn column)
Checks whether a given column is part of the primary key for this RowSet |
protected boolean |
prepareInitRecord(DBRecord rec,
int state,
java.lang.Object rowSetData)
Initialise this DBRowSet object and sets it's initial state. |
protected boolean |
readRecord(DBRecord rec,
DBCommand cmd,
java.sql.Connection conn)
Reads a single record from the database using the given command object. If a reocord is found the DBRecord object will hold all record data. |
boolean |
readRecord(DBRecord rec,
java.lang.Object[] key,
java.sql.Connection conn)
Reads the record with the given primary key from the database. |
boolean |
recordExists(java.lang.Object[] key,
java.sql.Connection conn)
Returns true if the record exists in the database or false otherwise. |
boolean |
recordExists(java.lang.Object id,
java.sql.Connection conn)
Returns true if the record exists in the database or false otherwise. |
void |
setComment(java.lang.String comment)
|
protected boolean |
setKeyConstraints(DBCommand cmd,
java.lang.Object[] key)
Set the constraints for a single record from a supplied key |
void |
setTimestampColumn(DBColumn timestampColumn)
|
boolean |
updateRecord(DBRecord rec,
java.sql.Connection conn)
Updates or Inserts a record in the database. Whether an update or insert is performed depends on the record state. Only modified fields will be inserted or updated in the database. |
Methods inherited from class org.apache.empire.db.DBExpr |
---|
addSQL, 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 static final org.slf4j.Logger log
protected final DBDatabase db
protected java.lang.String comment
protected DBIndex primaryKey
protected DBColumn timestampColumn
protected java.util.Map<DBColumn,DBColumn> columnReferences
protected java.util.List<DBColumn> columns
Constructor Detail |
---|
public DBRowSet(DBDatabase db)
db
- the database objectMethod Detail |
---|
public abstract java.lang.String getName()
public abstract java.lang.String getAlias()
public abstract boolean createRecord(DBRecord rec, java.sql.Connection conn)
public abstract boolean deleteRecord(java.lang.Object[] keys, java.sql.Connection conn)
public java.lang.String getFullName()
public void addReferencedColumns(java.util.Set<DBColumn> list)
DBExpr
addReferencedColumns
in class DBExpr
list
- list to which all used column expressions must be addedDBExpr.addReferencedColumns(Set)
public final DBDatabase getDatabase()
getDatabase
in class DBObject
public java.util.List<DBColumn> getColumns()
public int getColumnIndex(DBColumn column)
column
- column the DBColumn to get the index for
public final int getColumnIndex(Column column)
column
- the Column to get the index for
public DBColumn getColumn(int iColumn)
iColumn
- the index to get the DBColumn for
public DBColumn getColumn(java.lang.String name)
name
- the name of the column to look for
public boolean isColumnReadOnly(DBColumn col)
col
- the column object
public DBColumn[] getKeyColumns()
public boolean isKeyColumn(DBColumn column)
column
- the column to check
public java.lang.String getComment()
public void setComment(java.lang.String comment)
comment
- The comment to set.public DBColumn getTimestampColumn()
public void setTimestampColumn(DBColumn timestampColumn)
timestampColumn
- The timestampColumn to set.public java.util.Map<DBColumn,DBColumn> getColumnReferences()
protected boolean addColumnReference(DBColumn source, DBColumn target)
source
- a column reference for one of this table's columntarget
- the target column to which the source column referencespublic DBColumnExpr count()
protected java.lang.String getRenameTablePhrase()
public java.lang.Object[] getRecordKey(DBRecord rec)
rec
- the DBRecord object, contains all fields and the field properties
protected boolean prepareInitRecord(DBRecord rec, int state, java.lang.Object rowSetData)
rec
- the DBRecord object to initialise this DBRowSet objectstate
- the state of this DBRowSet object
public boolean initRecord(DBRecord rec, java.lang.Object[] keyValues)
rec
- the Record objectkeyValues
- an array of the primary key columns
public boolean initRecord(DBRecord rec, DBRecordData recData)
rec
- the record objectrecData
- the record data from which to initialized the record
protected boolean readRecord(DBRecord rec, DBCommand cmd, java.sql.Connection conn)
rec
- the DBRecord object which holds the record datacmd
- the SQL-Command used to query the recordconn
- a valid JDBC connection.
protected boolean completeInitRecord(DBRecord rec)
rec
- the DBRecord object to initialise
protected boolean setKeyConstraints(DBCommand cmd, java.lang.Object[] key)
cmd
- the command to which to add the constraintskey
- the record key
public boolean readRecord(DBRecord rec, java.lang.Object[] key, java.sql.Connection conn)
rec
- the DBRecord object which will hold the record datakey
- the primary key valuesconn
- a valid JDBC connection.
public boolean recordExists(java.lang.Object[] key, java.sql.Connection conn)
key
- an array of the primary key columnsconn
- a valid JDBC connection.
public final boolean recordExists(java.lang.Object id, java.sql.Connection conn)
id
- id of the recordconn
- a valid JDBC connection.
public boolean updateRecord(DBRecord rec, java.sql.Connection conn)
If a timestamp-column is set for this RowSet then a constraint will be added in the
update statement in order to detect concurrent changes.
If the record has been modified by another user, an error of type
DBErrors.RecordUpdateFailed will be set.
rec
- the DBRecord object. contains all fields and the field propertiesconn
- a valid JDBC connection.
public final boolean deleteRecord(java.lang.Object id, java.sql.Connection conn)
id
- the record's primary keyconn
- a valid JDBC connection
protected final boolean deleteAllReferences(java.lang.Object[] key, java.sql.Connection conn)
key
- the key the record to be deletedconn
- a valid connection
protected boolean deleteReferenceRecords(DBRelation.DBReference[] refs, java.lang.Object[] parentKey, java.sql.Connection conn)
refs
- the reference columns belonging to the releationparentKey
- the key of the parent elementconn
- a valid connection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |