org.apache.empire.db
Class DBView

java.lang.Object
  extended by org.apache.empire.commons.ErrorObject
      extended by org.apache.empire.db.DBObject
          extended by org.apache.empire.db.DBExpr
              extended by org.apache.empire.db.DBRowSet
                  extended by org.apache.empire.db.DBView
All Implemented Interfaces:
ErrorInfo

public abstract class DBView
extends DBRowSet

This class represent a view of the database. It consits methods to get and update records from the database


Nested Class Summary
static class DBView.DBViewColumn
           
 
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
 
Constructor Summary
DBView(java.lang.String name, DBDatabase db)
          Creates a view object for a given view in the database.
DBView(java.lang.String name, DBDatabase db, boolean isUpdateable)
          Creates a view object for a given view in the database.
 
Method Summary
 void addSQL(java.lang.StringBuilder buf, long context)
          Creates the SQL-Command adds the alias name to the SQL-Command.
abstract  DBCommandExpr createCommand()
          Returns the command required to create the view
This is function is only used for the creation of DDL statements
 boolean createRecord(DBRecord rec, java.sql.Connection conn)
           
 boolean deleteRecord(java.lang.Object[] keys, java.sql.Connection conn)
           
 DBView.DBViewColumn findViewColumn(DBColumnExpr expr)
          This function searchs for equal columns given by the specified DBColumnExpr object.
 java.lang.String getAlias()
          Returns the alias name of this object.
 java.lang.String getFullName()
          Returns the full qualified table name.
 java.lang.String getName()
          Returns the view name of this object.
 boolean isUpdateable()
          Returns whether or not the view is updateable
 boolean updateRecord(DBRecord rec, java.sql.Connection conn)
          Updates or Inserts a record in the database.
 
Methods inherited from class org.apache.empire.db.DBRowSet
addReferencedColumns, count, deleteRecord, getColumn, getColumn, getColumnIndex, getColumnIndex, getColumnReferences, getColumns, getComment, getDatabase, getKeyColumns, getRecordKey, getTimestampColumn, initRecord, initRecord, isColumnReadOnly, isKeyColumn, readRecord, recordExists, recordExists, setComment, setTimestampColumn
 
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
 

Constructor Detail

DBView

public DBView(java.lang.String name,
              DBDatabase db,
              boolean isUpdateable)
Creates a view object for a given view in the database.

Parameters:
name - the name of the view
db - the database this view belongs to.
isUpdateable - true if the records of this view can be updated

DBView

public DBView(java.lang.String name,
              DBDatabase db)
Creates a view object for a given view in the database.

Parameters:
name - the name of the view
db - the database this view belongs to.
Method Detail

createCommand

public abstract DBCommandExpr createCommand()
Returns the command required to create the view
This is function is only used for the creation of DDL statements

Returns:
a command expression that is used to create the view

getName

public java.lang.String getName()
Returns the view name of this object.

Specified by:
getName in class DBRowSet
Returns:
the view name of this object

getFullName

public java.lang.String getFullName()
Returns the full qualified table name.

Overrides:
getFullName in class DBRowSet
Returns:
the full qualified table name

getAlias

public java.lang.String getAlias()
Returns the alias name of this object.

Specified by:
getAlias in class DBRowSet
Returns:
the alias name of this object

isUpdateable

public boolean isUpdateable()
Returns whether or not the view is updateable

Returns:
true if the view is updateable or false if not

findViewColumn

public DBView.DBViewColumn findViewColumn(DBColumnExpr expr)
This function searchs for equal columns given by the specified DBColumnExpr object.

Parameters:
expr - the DBColumnExpr object
Returns:
the located column (only DBViewColumn onjects)

addSQL

public void addSQL(java.lang.StringBuilder buf,
                   long context)
Creates the SQL-Command adds the alias name to the SQL-Command.

Specified by:
addSQL in class DBExpr
Parameters:
buf - the SQL-Command
context - the current SQL-Command context

updateRecord

public boolean updateRecord(DBRecord rec,
                            java.sql.Connection conn)
Description copied from class: DBRowSet
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.

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.

Overrides:
updateRecord in class DBRowSet
Parameters:
rec - the DBRecord object. contains all fields and the field properties
conn - a valid JDBC connection.
Returns:
true if the update was sucessful or false otherwise

createRecord

public boolean createRecord(DBRecord rec,
                            java.sql.Connection conn)
Specified by:
createRecord in class DBRowSet

deleteRecord

public boolean deleteRecord(java.lang.Object[] keys,
                            java.sql.Connection conn)
Specified by:
deleteRecord in class DBRowSet