Class ElementContainerTable
java.lang.Object
org.datanucleus.store.rdbms.table.AbstractTable
org.datanucleus.store.rdbms.table.TableImpl
org.datanucleus.store.rdbms.table.JoinTable
org.datanucleus.store.rdbms.table.ElementContainerTable
- All Implemented Interfaces:
Table
,org.datanucleus.store.schema.table.Table
- Direct Known Subclasses:
ArrayTable
,CollectionTable
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
FieldsModifier and TypeFieldDescriptionprotected JavaTypeMapping
Mapping of an element.protected JavaTypeMapping
Order mapping, to provide part of the primary key.protected JavaTypeMapping
Optional mapping for a column used to discriminate between elements of one collection from another.protected String
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, ownerTable, ownerType
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByIdentifier, dba, existsInDatastore, identifier, state, storeMgr, TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED
-
Constructor Summary
ConstructorsConstructorDescriptionElementContainerTable
(Table ownerTable, DatastoreIdentifier tableName, org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyUserPrimaryKeySpecification
(org.datanucleus.metadata.PrimaryKeyMetaData pkmd) Convenience method to apply the user specification of <primary-key> columnsAccessor for the "element" mapping end of the relationship.abstract String
Access the element type class nameprotected List
<CandidateKey> Accessor for the candidate keys for this table.getExpectedForeignKeys
(org.datanucleus.ClassLoaderResolver clr) Accessor for the expected foreign keys for this table.getExpectedIndices
(org.datanucleus.ClassLoaderResolver clr) Accessor for the indices for this table.protected ForeignKey
getForeignKeyToElement
(DatastoreClass elementTable, boolean autoMode, JavaTypeMapping m) Convenience method to generate a ForeignKey from this join table to an element table using the specified mapping.protected ForeignKey
getForeignKeyToOwner
(DatastoreClass ownerTable, boolean autoMode) Convenience method to generate a ForeignKey from this join table to an owner table.getMemberMapping
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor not used by this table.Accessor for the order mapping.Accessor for the element discriminator mapping.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
getIdMapping, getOwnerMapping, getOwnerMemberMetaData, getOwnerTable, getPrimaryKey, requiresPrimaryKey
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, logMapping, validate, validateColumns, validateConstraints, validatePrimaryKey
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumn, addColumnInternal, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getClassMetaData, getColumn, getColumnForName, getColumnForPosition, getColumns, getDatastoreIdentifierFullyQualified, getDiscriminatorMetaData, getIdentifier, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getStoreManager, getSurrogateColumn, getSurrogateMapping, getVersionMetaData, hasColumn, hasColumnName, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, postInitialize, preInitialize, tableExistsInDatastore, toString
-
Field Details
-
elementMapping
Mapping of an element. This is either a PersistableMapping 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
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 andis of a type that can't be part of the PK. It will be specified in the MetaData using the <order> tag. -
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
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 Details
-
ElementContainerTable
public ElementContainerTable(Table ownerTable, DatastoreIdentifier tableName, org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr) Constructor.- Parameters:
ownerTable
- Table of the owner of this membertableName
- Identifier name of this tablemmd
- MetaData for the member owning this join tablestoreMgr
- The Store Manager managing these tables.
-
-
Method Details
-
initialize
public void initialize(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table definition. Adds the owner mapping.- Parameters:
clr
- The ClassLoaderResolver
-
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 <primary-key> columns- Parameters:
pkmd
- MetaData for the primary key
-
getMemberMapping
Accessor not used by this table.- Parameters:
mmd
- MetaData for the field whose mapping we want- Returns:
- The mapping
-
getElementMapping
Accessor for the "element" mapping end of the relationship. This is used where the element is persistable and has its own table (not embedded),or where the element is a simple type.- Returns:
- The column mapping for the element.
-
getOrderMapping
Accessor for the order mapping. The columns in this mapping are part of the primary key.- Returns:
- Order mapping (where required)
-
getRelationDiscriminatorMapping
Accessor for the element discriminator mapping.- Returns:
- Element discriminator mapping (where required)
-
getRelationDiscriminatorValue
Accessor for the element discriminator value.- Returns:
- Element discriminator value (where required)
-
getForeignKeyToOwner
Convenience method to generate a ForeignKey from this join table to an owner table.- Parameters:
ownerTable
- The owner tableautoMode
- Whether we are in auto mode (where we generate the keys regardless of what the metadata says)- Returns:
- The ForeignKey
-
getForeignKeyToElement
protected ForeignKey getForeignKeyToElement(DatastoreClass elementTable, boolean autoMode, JavaTypeMapping m) Convenience method to generate a ForeignKey from this join table to an element table using the specified mapping.- Parameters:
elementTable
- The element tableautoMode
- Whether we are in auto mode (where we generate the keys regardless of what the metadata says)m
- The mapping to the element table- Returns:
- The ForeignKey
-
getExpectedForeignKeys
Accessor for the expected foreign keys for this table.- Overrides:
getExpectedForeignKeys
in classTableImpl
- Parameters:
clr
- The ClassLoaderResolver- Returns:
- The expected foreign keys.
-
getExpectedIndices
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 classTableImpl
- Parameters:
clr
- The ClassLoaderResolver- Returns:
- The indices
-
getExpectedCandidateKeys
Accessor for the candidate keys for this table.- Overrides:
getExpectedCandidateKeys
in classTableImpl
- Returns:
- The indices
-