com.sun.jdo.api.persistence.model.mapping
Interface MappingTableElement

All Superinterfaces:
Comparable, MappingElement, MappingElementProperties, MappingMemberElement
All Known Implementing Classes:
MappingTableElementImpl

public interface MappingTableElement
extends MappingMemberElement

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
 void addKeyColumn(org.netbeans.modules.dbschema.ColumnElement column)
          Adds a column to the primary key of columns in this mapping table.
 void addReferencingKey(MappingReferenceKeyElement referencingKey)
          Adds a referencing key to the list of keys in this mapping table.
 ArrayList getKey()
          Returns the list of column names in the primary key for this mapping table.
 ArrayList getReferencingKeys()
          Returns the list of keys (MappingReferenceKeyElements) for this mapping table.
 String getTable()
          Returns the name of the table element used by this mapping table.
 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.
 void removeKeyColumn(String columnName)
          Removes a column from the primary key of columns in this mapping table.
 void removeReference(MappingTableElement table)
          Removes the referencing key for the supplied table element from list of keys in this mapping table.
 void setTable(org.netbeans.modules.dbschema.TableElement table)
          Set the table element for this mapping table to the supplied table.
 
Methods inherited from interface com.sun.jdo.api.persistence.model.mapping.MappingMemberElement
getDeclaringClass
 
Methods inherited from interface com.sun.jdo.api.persistence.model.mapping.MappingElement
addPropertyChangeListener, addVetoableChangeListener, getName, removePropertyChangeListener, removeVetoableChangeListener, setName
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getTable

String getTable()
Returns the name of the table element used by this mapping table.

Returns:
the table name for this mapping table

setTable

void setTable(org.netbeans.modules.dbschema.TableElement table)
              throws ModelException
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:
true if table elements are equal, false otherwise.

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

void addKeyColumn(org.netbeans.modules.dbschema.ColumnElement column)
                  throws ModelException
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

void removeKeyColumn(String columnName)
                     throws ModelException
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

void addReferencingKey(MappingReferenceKeyElement referencingKey)
                       throws ModelException
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

void removeReference(MappingTableElement table)
                     throws ModelException
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


Copyright © 2012 GlassFish Community. All Rights Reserved.