public class DBTable extends DBRowSet implements Cloneable
Modifier and Type | Field and Description |
---|---|
static int |
BIGINT |
static int |
DEFAULT |
static int |
MEDIUMINT |
static int |
SMALLINT |
columnReferences, columns, comment, db, log, primaryKey, timestampColumn
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE
Constructor and Description |
---|
DBTable(String name,
DBDatabase db)
Construct a new DBTable object set the specified parameters
to this object and add this object to the current database.
|
DBTable(String name,
DBDatabase db,
String alias)
Construct a new DBTable object set the specified parameters
to this object and add this object to the current database.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addColumn(DBTableColumn column)
Adds a column to this table's column list.
|
DBTableColumn |
addColumn(String columnName,
DataType type,
double size,
boolean required)
Creates a new DBTableColumn object and adds it to the column collection.
|
DBTableColumn |
addColumn(String columnName,
DataType type,
double size,
boolean required,
Object defValue)
Creates a new DBTableColumn object and adds it to the column collection.
|
DBTableColumn |
addColumn(String columnName,
DataType type,
double size,
DataMode dataMode)
Creates a new DBTableColumn object and adds it to the column collection.
|
DBTableColumn |
addColumn(String columnName,
DataType type,
double size,
DataMode dataMode,
Object defValue)
Creates a new DBTableColumn object and adds it to the column collection.
|
DBIndex |
addIndex(DBIndex index)
Adds an index.
|
DBIndex |
addIndex(String name,
boolean unique,
DBColumn... columns)
Adds an index.
|
void |
addSQL(StringBuilder buf,
long context)
Adds the table's name to the supplied sql command buffer.
|
DBTableColumn |
addTimestampColumn(String columnName)
Adds a timestamp column to the table used for optimistic locking.
|
Object |
clone()
Clones this table and assigns a new table alias.
|
void |
createRecord(DBRecord rec,
Connection conn)
Gets all table fields and the fields properties.
|
void |
deleteRecord(Object[] key,
Connection conn)
Creates a delete SQL-Command by using the DBCommand getDelete method
execute the the SQL-Command with the DBDatabase
executeSQL method.
|
String |
getAlias()
Returns the table alias name of this object.
|
DBRelation.DBCascadeAction |
getDefaultCascadeDeleteAction()
returns the default cascade action for deletes on this table.
|
List<DBRelation> |
getForeignKeyRelations()
Returns a list of all foreign key relations for this table
|
List<DBIndex> |
getIndexes()
Returns the list of indexes (except the primary key).
|
String |
getName()
Returns the table name of this object.
|
DBIndex |
getPrimaryKey()
Returns the primary key.
|
boolean |
isUpdateable()
Returns whether or not the table supports record updates.
|
void |
setDefaultCascadeDeleteAction(DBRelation.DBCascadeAction cascadeDeleteAction)
sets the default cascade action for deletes on foreign key relations.
|
void |
setPrimaryKey(DBColumn... columns)
Sets the primary keys.
|
addColumnReference, addReferencedColumns, completeInitRecord, count, deleteAllReferences, deleteRecord, deleteReferenceRecords, equals, findById, getColumn, getColumn, getColumnIndex, getColumnIndex, getColumnReferences, getColumns, getComment, getDatabase, getFullName, getId, getKeyColumns, getRecordKey, getRenameTablePhrase, getTimestampColumn, hashCode, initRecord, initRecord, isColumnReadOnly, isKeyColumn, prepareInitRecord, readRecord, readRecord, recordExists, recordExists, setComment, setKeyConstraints, setTimestampColumn, updateRecord
getObjectValue, getValueClass
public static final int DEFAULT
public static final int SMALLINT
public static final int MEDIUMINT
public static final int BIGINT
public DBTable(String name, DBDatabase db, String alias)
name
- the table namedb
- the valid database objectpublic DBTable(String name, DBDatabase db)
name
- the table namedb
- the valid database objectpublic String getName()
public String getAlias()
public boolean isUpdateable()
isUpdateable
in class DBRowSet
public Object clone() throws CloneNotSupportedException
This method requires that all declared column fields are NOT declared final. i.e. instead of: public final DBTableColumn MYCOL; columns must be declared: public DBTableColumn MYCOL; A runtime exception for the CloneNotSupported will be thrown if references cannot be adjusted. Alternatively a second table instance may be created manually like this: public final MyTable MYTABLE1 = new MyTable(); public final MyTable MYTABLE2 = new MyTable(); ... cmd.join(MYTABLE1.ID, MYTABLE2.PARENTID); // self-join ...
clone
in class Object
CloneNotSupportedException
protected void addColumn(DBTableColumn column)
column
- a column objectpublic final DBTableColumn addColumn(String columnName, DataType type, double size, DataMode dataMode, Object defValue)
columnName
- the column nametype
- the type of the column e.g. integer, text, datesize
- the column widthdataMode
- determines whether this column is optional, required or auto-generateddefValue
- a Object objectpublic final DBTableColumn addColumn(String columnName, DataType type, double size, DataMode dataMode)
columnName
- the column nametype
- the type of the column e.g. integer, text, datesize
- the column widthdataMode
- determines whether this column is optional, required or auto-generatedpublic final DBTableColumn addColumn(String columnName, DataType type, double size, boolean required, Object defValue)
columnName
- the column nametype
- the type of the column e.g. integer, text, datesize
- the column widthrequired
- true if not null columndefValue
- a Object objectpublic final DBTableColumn addColumn(String columnName, DataType type, double size, boolean required)
columnName
- the column nametype
- the type of the column e.g. integer, text, datesize
- the column widthrequired
- true if not null columnpublic DBIndex getPrimaryKey()
public List<DBIndex> getIndexes()
public void setPrimaryKey(DBColumn... columns)
columns
- a array with one or more DBColumn objectspublic final DBIndex addIndex(String name, boolean unique, DBColumn... columns)
name
- the index nameunique
- is this a unique indexcolumns
- the columns indexed by this indexpublic DBTableColumn addTimestampColumn(String columnName)
columnName
- the column namepublic void addSQL(StringBuilder buf, long context)
public void createRecord(DBRecord rec, Connection conn)
createRecord
in class DBRowSet
rec
- the DBRecord object. contains all fields and the field propertiesconn
- a valid connection to the database.public DBRelation.DBCascadeAction getDefaultCascadeDeleteAction()
public void setDefaultCascadeDeleteAction(DBRelation.DBCascadeAction cascadeDeleteAction)
cascadeDeleteAction
- cascade action for deletes (DBRelation.DBCascadeAction.CASCADE_RECORDS)public void deleteRecord(Object[] key, Connection conn)
deleteRecord
in class DBRowSet
key
- an array of the primary key columnsconn
- a valid connection to the database.public List<DBRelation> getForeignKeyRelations()
Copyright © 2008–2017 Apache Software Foundation. All rights reserved.