org.datanucleus.store.rdbms.table
Class ElementContainerTable

java.lang.Object
  extended by org.datanucleus.store.rdbms.table.AbstractTable
      extended by org.datanucleus.store.rdbms.table.TableImpl
          extended by org.datanucleus.store.rdbms.table.JoinTable
              extended by org.datanucleus.store.rdbms.table.ElementContainerTable
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreContainerObject, Table
Direct Known Subclasses:
ArrayTable, CollectionTable

public abstract class ElementContainerTable
extends JoinTable

Representation of a join table for a container of elements. Can be used for collections, lists, sets and arrays. There can be multiple JoinTable objects referring to the same underlying datastore object. If the JoinTable is shared by multiple fields for example then there will be one for each relation.


Field Summary
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping elementMapping
          Mapping of an element.
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping orderMapping
          Order mapping, to provide part of the primary key.
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping relationDiscriminatorMapping
          Optional mapping for a column used to discriminate between elements of one collection from another.
protected  java.lang.String relationDiscriminatorValue
          Value to use with any relation discriminator column for objects of this field placed in the join table.
 
Fields inherited from class org.datanucleus.store.rdbms.table.JoinTable
mmd, ownerMapping, ownerType
 
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByName, dba, existsInDatastore, identifier, LOCALISER, state, storeMgr
 
Constructor Summary
ElementContainerTable(org.datanucleus.store.mapped.DatastoreIdentifier tableName, org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSManager storeMgr)
          Constructor.
 
Method Summary
protected  void applyUserPrimaryKeySpecification(org.datanucleus.metadata.PrimaryKeyMetaData pkmd)
          Convenience method to apply the user specification of columns
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getElementMapping()
          Accessor for the "element" mapping end of the relationship.
abstract  java.lang.String getElementType()
          Access the element type class name
protected  java.util.List getExpectedCandidateKeys()
          Accessor for the candidate keys for this table.
protected  java.util.List getExpectedForeignKeys(org.datanucleus.ClassLoaderResolver clr)
          Accessor for the expected foreign keys for this table.
protected  java.util.Set getExpectedIndices(org.datanucleus.ClassLoaderResolver clr)
          Accessor for the indices for this table.
protected  ForeignKey getForeignKeyToElement(org.datanucleus.store.mapped.DatastoreClass elementTable, boolean autoMode, org.datanucleus.store.mapped.mapping.JavaTypeMapping m)
          Convenience method to generate a ForeignKey from this join table to an element table using the specified mapping.
protected  ForeignKey getForeignKeyToOwner(org.datanucleus.store.mapped.DatastoreClass ownerTable, boolean autoMode)
          Convenience method to generate a ForeignKey from this join table to an owner table.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          Accessor not used by this table.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getOrderMapping()
          Accessor for the order mapping.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getRelationDiscriminatorMapping()
          Accessor for the element discriminator mapping.
 java.lang.String getRelationDiscriminatorValue()
          Accessor for the element discriminator value.
 void initialize(org.datanucleus.ClassLoaderResolver clr)
          Method to initialise the table definition.
 
Methods inherited from class org.datanucleus.store.rdbms.table.JoinTable
debugMapping, getIDMapping, getOwnerMapping, getOwnerMemberMetaData, getPrimaryKey, requiresPrimaryKey
 
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, postInitialize, preInitialize, validate, validateColumns, validateConstraints, validatePrimaryKey
 
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumnInternal, addDatastoreField, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getDatastoreField, getDatastoreFields, getDatastoreIdentifierFullyQualified, getDiscriminatorMapping, getDiscriminatorMetaData, getIdentifier, getSchemaName, getStoreManager, getVersionMapping, getVersionMetaData, hasColumnName, hasDatastoreField, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, tableExistsInDatastore, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.datanucleus.store.mapped.DatastoreContainerObject
addDatastoreField, getDatastoreField, getDatastoreFields, getDiscriminatorMapping, getDiscriminatorMetaData, getIdentifier, getStoreManager, getVersionMapping, getVersionMetaData, hasDatastoreField
 

Field Detail

elementMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping elementMapping
Mapping of an element. This is either a PersistenceCapableMapping to the element table, or an EmbeddedElementPCMapping (when PC elements are embedded), or a simple mapping (when using non-PC elements), or a SerialisedPCMapping, or a SerialisedReferenceMapping. It will be specified in the MetaData using the <element> tag.


orderMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping orderMapping
Order mapping, to provide part of the primary key. In the case of a List this represents the ordering index. In the case of a Set this represents an index for allowing duplicates, or where the element is embedded and is of a type that can't be part of the PK. It will be specified in the MetaData using the <order> tag.


relationDiscriminatorMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping relationDiscriminatorMapping
Optional mapping for a column used to discriminate between elements of one collection from another. Used where the join table is being shared by more than 1 relation. Specified using the metadata extension "relation-discriminator-column" in the "field" element.


relationDiscriminatorValue

protected java.lang.String relationDiscriminatorValue
Value to use with any relation discriminator column for objects of this field placed in the join table. Specified using the metadata extension "relation-discriminator-value" in the "field" element.

Constructor Detail

ElementContainerTable

public ElementContainerTable(org.datanucleus.store.mapped.DatastoreIdentifier tableName,
                             org.datanucleus.metadata.AbstractMemberMetaData mmd,
                             RDBMSManager storeMgr)
Constructor.

Parameters:
tableName - Identifier name of the table
mmd - MetaData for the field/property owning this join table
storeMgr - The Store Manager managing these tables.
Method Detail

initialize

public void initialize(org.datanucleus.ClassLoaderResolver clr)
Method to initialise the table definition. Adds the owner mapping.

Parameters:
clr - The ClassLoaderResolver

getElementType

public abstract java.lang.String getElementType()
Access the element type class name

Returns:
the element type class name

applyUserPrimaryKeySpecification

protected void applyUserPrimaryKeySpecification(org.datanucleus.metadata.PrimaryKeyMetaData pkmd)
Convenience method to apply the user specification of columns

Parameters:
pkmd - MetaData for the primary key

getMemberMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor not used by this table.

Parameters:
mmd - MetaData for the field whose mapping we want
Returns:
The mapping

getElementMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getElementMapping()
Accessor for the "element" mapping end of the relationship. This is used where the element is PersistenceCapable and has its own table (not embedded), or where the element is a simple type.

Returns:
The column mapping for the element.

getOrderMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getOrderMapping()
Accessor for the order mapping. The columns in this mapping are part of the primary key.

Returns:
Order mapping (where required)

getRelationDiscriminatorMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getRelationDiscriminatorMapping()
Accessor for the element discriminator mapping.

Returns:
Element discriminator mapping (where required)

getRelationDiscriminatorValue

public java.lang.String getRelationDiscriminatorValue()
Accessor for the element discriminator value.

Returns:
Element discriminator value (where required)

getForeignKeyToOwner

protected ForeignKey getForeignKeyToOwner(org.datanucleus.store.mapped.DatastoreClass ownerTable,
                                          boolean autoMode)
Convenience method to generate a ForeignKey from this join table to an owner table.

Parameters:
ownerTable - The owner table
autoMode - Whether we are in auto mode (where JPOX generates the keys regardless of what the metadata says)
Returns:
The ForeignKey

getForeignKeyToElement

protected ForeignKey getForeignKeyToElement(org.datanucleus.store.mapped.DatastoreClass elementTable,
                                            boolean autoMode,
                                            org.datanucleus.store.mapped.mapping.JavaTypeMapping m)
Convenience method to generate a ForeignKey from this join table to an element table using the specified mapping.

Parameters:
elementTable - The element table
autoMode - Whether we are in auto mode (where JPOX generates the keys regardless of what the metadata says)
m - The mapping to the element table
Returns:
The ForeignKey

getExpectedForeignKeys

protected java.util.List getExpectedForeignKeys(org.datanucleus.ClassLoaderResolver clr)
Accessor for the expected foreign keys for this table.

Overrides:
getExpectedForeignKeys in class TableImpl
Parameters:
clr - The ClassLoaderResolver
Returns:
The expected foreign keys.

getExpectedIndices

protected java.util.Set getExpectedIndices(org.datanucleus.ClassLoaderResolver clr)
Accessor for the indices for this table. This includes both the user-defined indices (via MetaData), and the ones required by foreign keys (required by relationships).

Overrides:
getExpectedIndices in class TableImpl
Parameters:
clr - The ClassLoaderResolver
Returns:
The indices

getExpectedCandidateKeys

protected java.util.List getExpectedCandidateKeys()
Accessor for the candidate keys for this table.

Overrides:
getExpectedCandidateKeys in class TableImpl
Returns:
The indices


Copyright © 2009. All Rights Reserved.