Interface MappingTableElement
- All Superinterfaces:
Comparable,MappingElement,MappingElementProperties,MappingMemberElement
- All Known Implementing Classes:
MappingTableElementImpl
This is an element which represents a database table. It exists (separately
from TableElement in the database model) to allow the runtime to use a
description of the underlying table that differs from the actual database.
For example, mapping table contains a key which can be thought of as a
"fake primary key" and designates the columns which the runtime will use
to identify rows. It is analagous to the primary key of the underlying
database table and is typically the same, however the important point
is that it is not a requirement. The table in the database may have a
different primary key or may have no primary key at all. Similarly, the
mapping table contains a list of reference keys which can be thought of as
"fake foreign key" objects and designate the column pairs used to join
the primary table with a secondary table. These are analagous to
foreign keys and may in fact contain identical pairs as the foreign key,
but again, this is not a requirement. The foreign key may define a
different set of pairs or may not exist at all. Although any set of pairs
is legal, the user should be careful to define pairs which represent a
logical relationship between the two tables.
Any mapping table elements which are designated as primary tables have
their key set up automatically. Any mapping table elements which are
designated as secondary tables should not have their keys set up directly;
the setup is automatically part of the pair definition which makes up the
reference key.
- Version:
- %I%
- Author:
- Mark Munro, Rochelle Raccah
-
Field Summary
Fields inherited from interface com.sun.jdo.api.persistence.model.mapping.MappingElementProperties
PROP_ASSOCIATED_COLUMNS, PROP_COLUMNS, PROP_CONSISTENCY, PROP_DATABASE_ROOT, PROP_FETCH_GROUP, PROP_FIELDS, PROP_IN_CONCURRENCY_CHECK, PROP_KEY_COLUMNS, PROP_MODIFIED, PROP_NAME, PROP_NAVIGABLE, PROP_READ_ONLY, PROP_REFERENCING_KEYS, PROP_TABLE, PROP_TABLES, PROP_VERSION_FIELD -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyColumn(org.netbeans.modules.dbschema.ColumnElement column) Adds a column to the primary key of columns in this mapping table.voidaddReferencingKey(MappingReferenceKeyElement referencingKey) Adds a referencing key to the list of keys in this mapping table.getKey()Returns the list of column names in the primary key for this mapping table.Returns the list of keys (MappingReferenceKeyElements) for this mapping table.getTable()Returns the name of the table element used by this mapping table.booleanisEqual(org.netbeans.modules.dbschema.TableElement table) Returns true if the table element used by this mapping table is equal to the supplied table.voidremoveKeyColumn(String columnName) Removes a column from the primary key of columns in this mapping table.voidRemoves the referencing key for the supplied table element from list of keys in this mapping table.voidsetTable(org.netbeans.modules.dbschema.TableElement table) Set the table element for this mapping table to the supplied table.Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.sun.jdo.api.persistence.model.mapping.MappingElement
addPropertyChangeListener, addVetoableChangeListener, getName, removePropertyChangeListener, removeVetoableChangeListener, setNameMethods inherited from interface com.sun.jdo.api.persistence.model.mapping.MappingMemberElement
getDeclaringClass
-
Method Details
-
getTable
String getTable()Returns the name of the table element used by this mapping table.- Returns:
- the table name for this mapping table
-
setTable
Set the table element for this mapping table to the supplied table.- Parameters:
table- table element to be used by the mapping table.- Throws:
ModelException- if impossible
-
isEqual
boolean isEqual(org.netbeans.modules.dbschema.TableElement table) Returns true if the table element used by this mapping table is equal to the supplied table.- Returns:
trueif table elements are equal,falseotherwise.
-
getKey
ArrayList getKey()Returns the list of column names in the primary key for this mapping table.- Returns:
- the names of the columns in the primary key for this mapping table
-
addKeyColumn
Adds a column to the primary key of columns in this mapping table. This method should only be used to manipulate the key columns of the primary table. The secondary table key columns should be manipulated using MappingReferenceKeyElement methods for pairs.- Parameters:
column- column element to be added- Throws:
ModelException- if impossible
-
removeKeyColumn
Removes a column from the primary key of columns in this mapping table. This method should only be used to manipulate the key columns of the primary table. The secondary table key columns should be manipulated using MappingReferenceKeyElement methods for pairs.- Parameters:
columnName- the relative name of the column to be removed- Throws:
ModelException- if impossible
-
getReferencingKeys
ArrayList getReferencingKeys()Returns the list of keys (MappingReferenceKeyElements) for this mapping table. There will be keys for foreign keys and "fake" foreign keys.- Returns:
- the reference key elements for this mapping table
-
addReferencingKey
Adds a referencing key to the list of keys in this mapping table.- Parameters:
referencingKey- referencing key element to be added- Throws:
ModelException- if impossible
-
removeReference
Removes the referencing key for the supplied table element from list of keys in this mapping table.- Parameters:
table- mapping table element for which to remove referencing keys- Throws:
ModelException- if impossible
-