|
|||||||||
| Home >> All >> org >> apache >> torque >> engine >> database >> [ model overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.torque.engine.database.model
Class Table

java.lang.Objectorg.apache.torque.engine.database.model.Table
- All Implemented Interfaces:
- IDMethod
- public class Table
- extends java.lang.Object
- implements IDMethod
- extends java.lang.Object
Data about a table used in an application.
- Version:
- $Id: Table.java,v 1.3.2.4 2004/08/23 00:29:52 seade Exp $
| Fields inherited from interface org.apache.torque.engine.database.model.IDMethod |
AUTO_INCREMENT, ID_BROKER, NATIVE, NO_ID_METHOD, SEQUENCE |
| Constructor Summary | |
Table()
Default Constructor |
|
Table(java.lang.String name)
Constructs a table object with a name |
|
| Method Summary | |
private java.lang.String |
acquireConstraintName(java.lang.String nameType,
int nbr)
Macro to a constraint name. |
Column |
addColumn(org.xml.sax.Attributes attrib)
A utility function to create a new column from attrib and add it to this table. |
void |
addColumn(Column col)
Adds a new column to the column list and set the parent table of the column to the current table |
ForeignKey |
addForeignKey(org.xml.sax.Attributes attrib)
A utility function to create a new foreign key from attrib and add it to this table. |
void |
addForeignKey(ForeignKey fk)
Adds a new FK to the FK list and set the parent table of the column to the current table |
IdMethodParameter |
addIdMethodParameter(org.xml.sax.Attributes attrib)
A utility function to create a new id method parameter from attrib and add it to this table. |
void |
addIdMethodParameter(IdMethodParameter imp)
Adds a new ID method parameter to the list and sets the parent table of the column associated with the supplied parameter to this table. |
Index |
addIndex(org.xml.sax.Attributes attrib)
A utility function to create a new index from attrib and add it to this table. |
void |
addIndex(Index index)
Adds a new index to the index list and set the parent table of the column to the current table |
void |
addReferrer(ForeignKey fk)
Adds the foreign key from another table that refers to this table. |
Unique |
addUnique(org.xml.sax.Attributes attrib)
A utility function to create a new Unique from attrib and add it to this table. |
void |
addUnique(Unique unique)
Adds a new Unique to the Unique list and set the parent table of the column to the current table |
boolean |
containsColumn(Column col)
Returns true if the table contains a specified column |
boolean |
containsColumn(java.lang.String name)
Returns true if the table contains a specified column |
void |
doFinalInitialization()
A hook for the SAX XML parser to call when this table has been fully loaded from the XML, and all nested elements have been processed. |
private void |
doHeavyIndexing()
Adds extra indices for multi-part primary key columns. |
private void |
doNaming()
Names composing objects which haven't yet been named. |
java.lang.String |
getAlias()
JavaName of om object this entry references. |
java.lang.String |
getBaseClass()
Gets the value of base class for classes produced from this table. |
java.lang.String |
getBasePeer()
Get the value of basePeer. |
Column |
getChildrenColumn()
Gets the column that subclasses of the class representing this table can be produced from. |
java.util.List |
getChildrenNames()
Get the objects that can be created from this table. |
Column |
getColumn(java.lang.String name)
Returns a specified column. |
Column |
getColumnByJavaName(java.lang.String javaName)
Returns a specified column. |
Column[] |
getColumns()
Returns an Array containing all the columns in the table |
boolean |
getContainsForeignPK()
Determine if this table contains a foreign PK |
Database |
getDatabase()
Get the parent of the table |
java.lang.String |
getDescription()
Get the description for the Table |
ForeignKey |
getForeignKey(java.lang.String col)
Return the first foreign key that includes col in it's list of local columns. |
ForeignKey[] |
getForeignKeys()
Returns an Array containing all the FKs in the table |
java.util.List |
getForeignTableNames()
A list of tables referenced by foreign keys in this table |
java.lang.String |
getIdMethod()
Get the method for generating pk's |
java.util.List |
getIdMethodParameters()
Returns a Collection of parameters relevant for the chosen id generation method. |
Index[] |
getIndices()
Returns an Array containing all the indices in the table |
java.lang.String |
getInterface()
Interface which objects for this table will implement |
java.lang.String |
getJavaName()
Get name to use in Java sources |
java.lang.String |
getName()
Get the name of the Table |
int |
getNumColumns()
Utility method to get the number of columns in this table |
java.lang.String |
getPackage()
Get the value of package. |
java.util.List |
getPrimaryKey()
Returns the collection of Columns which make up the single primary key for this table. |
java.util.List |
getReferrers()
Get list of references to this table. |
java.lang.String |
getSequenceName()
A name to use for creating a sequence if one is not specified. |
Unique[] |
getUnices()
Returns an Array containing all the UKs in the table |
boolean |
hasPrimaryKey()
Determine whether this table has a primary key. |
boolean |
isAbstract()
When a table is abstract, it marks the business object class that is generated as being abstract. |
boolean |
isAlias()
Is this table specified in the schema or is there just a foreign key reference to it. |
boolean |
isForReferenceOnly()
Flag to determine if code/sql gets created for this table. |
boolean |
isSkipSql()
Skip generating sql for this table (in the event it should not be created from scratch). |
void |
loadFromXML(org.xml.sax.Attributes attrib,
java.lang.String defaultIdMethod)
Load the table object from an xml tag. |
private java.lang.String |
printList(java.util.List list)
Returns the elements of the list, separated by commas. |
java.lang.String |
printPrimaryKey()
Returns all parts of the primary key, separated by commas. |
boolean |
requiresTransactionInPostgres()
Return true if the column requires a transaction in Postgres |
void |
setAbstract(boolean v)
When a table is abstract, it marks the business object class that is generated as being abstract. |
void |
setAlias(java.lang.String v)
Set whether this table specified in the schema or is there just a foreign key reference to it. |
void |
setBaseClass(java.lang.String v)
Set the value of baseClass. |
void |
setBasePeer(java.lang.String v)
Set the value of basePeer. |
void |
setContainsForeignPK(boolean b)
Set whether this table contains a foreign PK |
void |
setDatabase(Database parent)
Set the parent of the table |
void |
setDescription(java.lang.String newDescription)
Set the description for the Table |
void |
setForReferenceOnly(boolean v)
Flag to determine if code/sql gets created for this table. |
void |
setIdMethod(java.lang.String idMethod)
Set the method for generating pk's |
void |
setInterface(java.lang.String v)
Interface which objects for this table will implement |
void |
setJavaName(java.lang.String javaName)
Set name to use in Java sources |
void |
setName(java.lang.String newName)
Set the name of the Table |
void |
setPackage(java.lang.String v)
Set the value of package. |
void |
setSkipSql(boolean v)
Set whether this table should have its creation sql generated. |
java.lang.String |
toString()
Returns a XML representation of this table. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
log
private static org.apache.commons.logging.Log log
- Logging class from commons.logging
columnList
private java.util.List columnList
foreignKeys
private java.util.List foreignKeys
indices
private java.util.List indices
unices
private java.util.List unices
idMethodParameters
private java.util.List idMethodParameters
name
private java.lang.String name
description
private java.lang.String description
javaName
private java.lang.String javaName
idMethod
private java.lang.String idMethod
javaNamingMethod
private java.lang.String javaNamingMethod
tableParent
private Database tableParent
referrers
private java.util.List referrers
foreignTableNames
private java.util.List foreignTableNames
containsForeignPK
private boolean containsForeignPK
inheritanceColumn
private Column inheritanceColumn
skipSql
private boolean skipSql
abstractValue
private boolean abstractValue
alias
private java.lang.String alias
enterface
private java.lang.String enterface
pkg
private java.lang.String pkg
baseClass
private java.lang.String baseClass
basePeer
private java.lang.String basePeer
columnsByName
private java.util.Hashtable columnsByName
columnsByJavaName
private java.util.Hashtable columnsByJavaName
needsTransactionInPostgres
private boolean needsTransactionInPostgres
heavyIndexing
private boolean heavyIndexing
forReferenceOnly
private boolean forReferenceOnly
| Constructor Detail |
Table
public Table()
- Default Constructor
Table
public Table(java.lang.String name)
- Constructs a table object with a name
| Method Detail |
loadFromXML
public void loadFromXML(org.xml.sax.Attributes attrib, java.lang.String defaultIdMethod)
- Load the table object from an xml tag.
doFinalInitialization
public void doFinalInitialization()
A hook for the SAX XML parser to call when this table has been fully loaded from the XML, and all nested elements have been processed.
Performs heavy indexing and naming of elements which weren't provided with a name.
doHeavyIndexing
private void doHeavyIndexing()
Adds extra indices for multi-part primary key columns.
For databases like MySQL, values in a where clause must match key part order from the left to right. So, in the key definition
PRIMARY KEY (FOO_ID, BAR_ID),FOO_IDmust be the first element used in thewhereclause of the SQL query used against this table for the primary key index to be used. This feature could cause problems under MySQL with heavily indexed tables, as MySQL currently only supports 16 indices per table (i.e. it might cause too many indices to be created).See the manual for a better description of why heavy indexing is useful for quickly searchable database tables.
doNaming
private void doNaming()
- Names composing objects which haven't yet been named. This
currently consists of foreign-key and index entities.
acquireConstraintName
private final java.lang.String acquireConstraintName(java.lang.String nameType, int nbr) throws org.apache.torque.engine.EngineException
- Macro to a constraint name.
getBaseClass
public java.lang.String getBaseClass()
- Gets the value of base class for classes produced from this table.
setBaseClass
public void setBaseClass(java.lang.String v)
- Set the value of baseClass.
getBasePeer
public java.lang.String getBasePeer()
- Get the value of basePeer.
setBasePeer
public void setBasePeer(java.lang.String v)
- Set the value of basePeer.
addColumn
public Column addColumn(org.xml.sax.Attributes attrib)
- A utility function to create a new column from attrib and add it to this
table.
addColumn
public void addColumn(Column col)
- Adds a new column to the column list and set the
parent table of the column to the current table
addForeignKey
public ForeignKey addForeignKey(org.xml.sax.Attributes attrib)
- A utility function to create a new foreign key
from attrib and add it to this table.
getChildrenColumn
public Column getChildrenColumn()
- Gets the column that subclasses of the class representing this
table can be produced from.
getChildrenNames
public java.util.List getChildrenNames()
- Get the objects that can be created from this table.
addReferrer
public void addReferrer(ForeignKey fk)
- Adds the foreign key from another table that refers to this table.
getReferrers
public java.util.List getReferrers()
- Get list of references to this table.
setContainsForeignPK
public void setContainsForeignPK(boolean b)
- Set whether this table contains a foreign PK
getContainsForeignPK
public boolean getContainsForeignPK()
- Determine if this table contains a foreign PK
getForeignTableNames
public java.util.List getForeignTableNames()
- A list of tables referenced by foreign keys in this table
addForeignKey
public void addForeignKey(ForeignKey fk)
- Adds a new FK to the FK list and set the
parent table of the column to the current table
requiresTransactionInPostgres
public boolean requiresTransactionInPostgres()
- Return true if the column requires a transaction in Postgres
addIdMethodParameter
public IdMethodParameter addIdMethodParameter(org.xml.sax.Attributes attrib)
- A utility function to create a new id method parameter
from attrib and add it to this table.
addIdMethodParameter
public void addIdMethodParameter(IdMethodParameter imp)
- Adds a new ID method parameter to the list and sets the parent
table of the column associated with the supplied parameter to this table.
addIndex
public void addIndex(Index index)
- Adds a new index to the index list and set the
parent table of the column to the current table
addIndex
public Index addIndex(org.xml.sax.Attributes attrib)
- A utility function to create a new index
from attrib and add it to this table.
addUnique
public void addUnique(Unique unique)
- Adds a new Unique to the Unique list and set the
parent table of the column to the current table
addUnique
public Unique addUnique(org.xml.sax.Attributes attrib)
- A utility function to create a new Unique
from attrib and add it to this table.
getName
public java.lang.String getName()
- Get the name of the Table
setName
public void setName(java.lang.String newName)
- Set the name of the Table
getDescription
public java.lang.String getDescription()
- Get the description for the Table
setDescription
public void setDescription(java.lang.String newDescription)
- Set the description for the Table
getJavaName
public java.lang.String getJavaName()
- Get name to use in Java sources
setJavaName
public void setJavaName(java.lang.String javaName)
- Set name to use in Java sources
getIdMethod
public java.lang.String getIdMethod()
- Get the method for generating pk's
setIdMethod
public void setIdMethod(java.lang.String idMethod)
- Set the method for generating pk's
isSkipSql
public boolean isSkipSql()
- Skip generating sql for this table (in the event it should
not be created from scratch).
setSkipSql
public void setSkipSql(boolean v)
- Set whether this table should have its creation sql generated.
getAlias
public java.lang.String getAlias()
- JavaName of om object this entry references.
isAlias
public boolean isAlias()
- Is this table specified in the schema or is there just
a foreign key reference to it.
setAlias
public void setAlias(java.lang.String v)
- Set whether this table specified in the schema or is there just
a foreign key reference to it.
getInterface
public java.lang.String getInterface()
- Interface which objects for this table will implement
setInterface
public void setInterface(java.lang.String v)
- Interface which objects for this table will implement
isAbstract
public boolean isAbstract()
- When a table is abstract, it marks the business object class that is
generated as being abstract. If you have a table called "FOO", then the
Foo BO will be
public abstract class FooThis helps support class hierarchies
setAbstract
public void setAbstract(boolean v)
- When a table is abstract, it marks the business object
class that is generated as being abstract. If you have a
table called "FOO", then the Foo BO will be
public abstract class FooThis helps support class hierarchies
getPackage
public java.lang.String getPackage()
- Get the value of package.
setPackage
public void setPackage(java.lang.String v)
- Set the value of package.
getColumns
public Column[] getColumns()
- Returns an Array containing all the columns in the table
getNumColumns
public int getNumColumns()
- Utility method to get the number of columns in this table
getForeignKeys
public ForeignKey[] getForeignKeys()
- Returns an Array containing all the FKs in the table
getIdMethodParameters
public java.util.List getIdMethodParameters()
- Returns a Collection of parameters relevant for the chosen
id generation method.
getSequenceName
public java.lang.String getSequenceName()
- A name to use for creating a sequence if one is not specified.
getIndices
public Index[] getIndices()
- Returns an Array containing all the indices in the table
getUnices
public Unique[] getUnices()
- Returns an Array containing all the UKs in the table
getColumn
public Column getColumn(java.lang.String name)
- Returns a specified column.
getColumnByJavaName
public Column getColumnByJavaName(java.lang.String javaName)
- Returns a specified column.
getForeignKey
public ForeignKey getForeignKey(java.lang.String col)
- Return the first foreign key that includes col in it's list
of local columns. Eg. Foreign key (a,b,c) refrences tbl(x,y,z)
will be returned of col is either a,b or c.
containsColumn
public boolean containsColumn(Column col)
- Returns true if the table contains a specified column
containsColumn
public boolean containsColumn(java.lang.String name)
- Returns true if the table contains a specified column
setDatabase
public void setDatabase(Database parent)
- Set the parent of the table
getDatabase
public Database getDatabase()
- Get the parent of the table
isForReferenceOnly
public boolean isForReferenceOnly()
- Flag to determine if code/sql gets created for this table.
Table will be skipped, if return true.
setForReferenceOnly
public void setForReferenceOnly(boolean v)
- Flag to determine if code/sql gets created for this table.
Table will be skipped, if set to true.
toString
public java.lang.String toString()
- Returns a XML representation of this table.
getPrimaryKey
public java.util.List getPrimaryKey()
- Returns the collection of Columns which make up the single primary
key for this table.
hasPrimaryKey
public boolean hasPrimaryKey()
- Determine whether this table has a primary key.
printPrimaryKey
public java.lang.String printPrimaryKey()
- Returns all parts of the primary key, separated by commas.
printList
private java.lang.String printList(java.util.List list)
- Returns the elements of the list, separated by commas.
|
|||||||||
| Home >> All >> org >> apache >> torque >> engine >> database >> [ model overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.torque.engine.database.model.Table