Package org.apache.torque.map
Class TableMap
java.lang.Object
org.apache.torque.map.OptionSupport
org.apache.torque.map.TableMap
- All Implemented Interfaces:
Serializable
TableMap is used to model a table in a database.
- Version:
- $Id: TableMap.java 1917245 2024-04-21 14:06:23Z tv $
- Author:
- John D. McNally, Daniel Rall, Greg Monroe
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTableMap(String tableName, String prefix, DatabaseMap containingDB) Constructor.TableMap(String tableName, DatabaseMap containingDB) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a pre-created column to this table.voidaddForeignKey(ForeignKeyMap foreignKey) Add a foreign key to this table.booleancontainsColumn(String name) Does this table contain the specified column?booleancontainsColumn(ColumnMap column) Does this table contain the specified column?booleanReturns true if this tableMap contains a column with object data.Get a ColumnMap for the named table.Get a ColumnMap[] of the columns in this table.Get the DatabaseMap containing this TableMap.getDbMap()Returns the database map for this table.Returns the table description info.Get all foreign keys in the table..Returns the fully qualified table name, if available.Get the Java name of the table as defined in XML.Class<?> Returns the manager class for this table.getName()Get the name of the Table, not prefixed by a possible schema nameClass<?> Returns the OM class for this table.Class<?> Returns the Peer Class for this table.Get table prefix name.Returns the single primary key of this table, if it existsGet the method used to generate primary keys for this table.getPrimaryKeyMethodInfo(IDMethod idMethod) Get the information used to generate a primary keyGet the schema to which the table belongs to.booleanReturns whether this table uses inheritance.booleanReturns whether managers are used for this table.final StringremoveUnderScores(String data) Removes the PREFIX, removes the underscores and makes first letter caps.voidsetDescription(String description) Sets the table description.voidsetJavaName(String value) Set the Java name of the table as defined by generator/XML.voidsetManagerClass(Class<?> managerClass) Sets the manager class for this table.voidsetOMClass(Class<?> omClass) Sets the OM root class for this table.voidsetPeerClass(Class<?> peerClass) Sets the Peer class for this table.voidSet table prefix name.voidsetPrimaryKeyMethod(IDMethod method) Sets the method used to generate a key for this table.voidsetPrimaryKeyMethodInfo(Object pkInfo) Sets the pk information needed to generate a key.voidsetPrimaryKeyMethodInfo(IDMethod idMethod, Object pkInfo) Sets the pk information needed to generate a key.voidsetUseInheritance(boolean useInheritance) Sets whether this table uses inheritance.voidsetUseManager(boolean useManager) Sets whether managers are used for this table.toString()Methods inherited from class org.apache.torque.map.OptionSupport
clearOptions, getOption, getOptions, setOption
-
Constructor Details
-
TableMap
Constructor.- Parameters:
tableName- The name of the table, may be prefixed with a schema name, not null.containingDB- A DatabaseMap that this table belongs to.
-
TableMap
Constructor.- Parameters:
tableName- The name of the table, may be prefixed with a schema name, not null.prefix- The prefix for the table name (ie: SCARAB for SCARAB_PROJECT).containingDB- A DatabaseMap that this table belongs to.
-
-
Method Details
-
containsColumn
Does this table contain the specified column?- Parameters:
column- A ColumnMap.- Returns:
- True if the table contains the column.
-
containsColumn
Does this table contain the specified column?- Parameters:
name- A String with the name of the column.- Returns:
- True if the table contains the column.
-
getDatabaseMap
Get the DatabaseMap containing this TableMap.- Returns:
- A DatabaseMap.
-
containsObjectColumn
public boolean containsObjectColumn()Returns true if this tableMap contains a column with object data. If the type of the column is not a string, a number or a date, it is assumed that it is object data.- Returns:
- True if map contains a column with object data.
-
getName
Get the name of the Table, not prefixed by a possible schema name- Returns:
- A String with the name of the table, not null.
-
getSchemaName
Get the schema to which the table belongs to.- Returns:
- the schema name, or null if the default schema should be used.
-
getFullyQualifiedTableName
Returns the fully qualified table name, if available.- Returns:
- the fully qualified table name, if a schema is set, or just the table name if no schema is set, not null.
-
getJavaName
Get the Java name of the table as defined in XML.- Returns:
- A String with the Java name of the table.
-
setJavaName
Set the Java name of the table as defined by generator/XML.- Parameters:
value- A String with the Java name of the table.
-
getPrefix
Get table prefix name.- Returns:
- A String with the prefix.
-
setPrefix
Set table prefix name.- Parameters:
prefix- The prefix for the table name (ie: SCARAB for SCARAB_PROJECT).
-
getPrimaryKeyMethod
Get the method used to generate primary keys for this table.- Returns:
- A String with the method.
-
getPrimaryKeyMethodInfo
Get the information used to generate a primary key- Parameters:
idMethod-IDMethodused to generate a primary key- Returns:
- An Object.
-
getColumns
Get a ColumnMap[] of the columns in this table.- Returns:
- A ColumnMap[].
-
getForeignKeys
Get all foreign keys in the table..- Returns:
- All foreign keys, not null.
-
getColumn
Get a ColumnMap for the named table.- Parameters:
name- A String with the name of the table.- Returns:
- A ColumnMap.
-
addColumn
Add a pre-created column to this table. It will replace any existing column.- Parameters:
cmap- A ColumnMap.
-
addForeignKey
Add a foreign key to this table.- Parameters:
foreignKey- the foreign key map, not null
-
setPrimaryKeyMethod
Sets the method used to generate a key for this table. Valid values are as specified in theIDMethodinterface.- Parameters:
method- The ID generation method type, not null.
-
setPrimaryKeyMethodInfo
Sets the pk information needed to generate a key. This overrides all information set bysetPrimaryKeyMethodInfo(String, Object).- Parameters:
pkInfo- information needed to generate a key
-
setPrimaryKeyMethodInfo
Sets the pk information needed to generate a key.- Parameters:
idMethod- the id method for which this information is stored.pkInfo- information needed to generate a key.
-
removeUnderScores
Removes the PREFIX, removes the underscores and makes first letter caps. SCARAB_FOO_BAR becomes FooBar.- Parameters:
data- A String.- Returns:
- A String with data processed.
-
getDescription
Returns the table description info.- Returns:
- Returns the description.
-
setDescription
Sets the table description.- Parameters:
description- The description to set.
-
getOMClass
Returns the OM class for this table.- Returns:
- the OM class.
-
setOMClass
Sets the OM root class for this table.- Parameters:
omClass- The OM root class for this table.
-
getPeerClass
Returns the Peer Class for this table.- Returns:
- The peerClass for this table.
-
setPeerClass
Sets the Peer class for this table.- Parameters:
peerClass- The peerClass to set.
-
getDbMap
Returns the database map for this table.- Returns:
- the database map for this table.
-
isUseInheritance
public boolean isUseInheritance()Returns whether this table uses inheritance.- Returns:
- whether inheritance is used.
-
setUseInheritance
public void setUseInheritance(boolean useInheritance) Sets whether this table uses inheritance.- Parameters:
useInheritance- whether this table uses inheritance.
-
isUseManager
public boolean isUseManager()Returns whether managers are used for this table.- Returns:
- whether managers are used for this table.
-
setUseManager
public void setUseManager(boolean useManager) Sets whether managers are used for this table.- Parameters:
useManager- whether managers are used for this table.
-
getManagerClass
Returns the manager class for this table.- Returns:
- the managerClass.
-
setManagerClass
Sets the manager class for this table.- Parameters:
managerClass- the manager class for this table.
-
getPrimaryKey
Returns the single primary key of this table, if it exists- Returns:
- the single primary key column.
- Throws:
TorqueException- If the table has no primary key or if the table has multiple primary keys.
-
toString
-