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
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
Fields Modifier and Type Field Description protected JavaTypeMapping
elementMapping
Mapping of an element.protected JavaTypeMapping
orderMapping
Order mapping, to provide part of the primary key.protected JavaTypeMapping
relationDiscriminatorMapping
Optional mapping for a column used to discriminate between elements of one collection from another.protected 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, 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
Constructors Constructor Description ElementContainerTable(Table ownerTable, DatastoreIdentifier tableName, org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
applyUserPrimaryKeySpecification(org.datanucleus.metadata.PrimaryKeyMetaData pkmd)
Convenience method to apply the user specification of <primary-key> columnsJavaTypeMapping
getElementMapping()
Accessor for the "element" mapping end of the relationship.abstract String
getElementType()
Access the element type class nameprotected List<CandidateKey>
getExpectedCandidateKeys()
Accessor for the candidate keys for this table.List<ForeignKey>
getExpectedForeignKeys(org.datanucleus.ClassLoaderResolver clr)
Accessor for the expected foreign keys for this table.protected Set<Index>
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.JavaTypeMapping
getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor not used by this table.JavaTypeMapping
getOrderMapping()
Accessor for the order mapping.JavaTypeMapping
getRelationDiscriminatorMapping()
Accessor for the element discriminator mapping.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
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 Detail
-
elementMapping
protected JavaTypeMapping 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
protected 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 andis of a type that can't be part of the PK. It will be specified in the MetaData using the <order> tag.
-
relationDiscriminatorMapping
protected 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 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(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 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 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 <primary-key> columns- Parameters:
pkmd
- MetaData for the primary key
-
getMemberMapping
public 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 JavaTypeMapping 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
public 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 JavaTypeMapping getRelationDiscriminatorMapping()
Accessor for the element discriminator mapping.- Returns:
- Element discriminator mapping (where required)
-
getRelationDiscriminatorValue
public String getRelationDiscriminatorValue()
Accessor for the element discriminator value.- Returns:
- Element discriminator value (where required)
-
getForeignKeyToOwner
protected ForeignKey getForeignKeyToOwner(DatastoreClass ownerTable, boolean autoMode)
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
public List<ForeignKey> getExpectedForeignKeys(org.datanucleus.ClassLoaderResolver clr)
Accessor for the expected foreign keys for this table.- Overrides:
getExpectedForeignKeys
in classTableImpl
- Parameters:
clr
- The ClassLoaderResolver- Returns:
- The expected foreign keys.
-
getExpectedIndices
protected Set<Index> 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 classTableImpl
- Parameters:
clr
- The ClassLoaderResolver- Returns:
- The indices
-
getExpectedCandidateKeys
protected List<CandidateKey> getExpectedCandidateKeys()
Accessor for the candidate keys for this table.- Overrides:
getExpectedCandidateKeys
in classTableImpl
- Returns:
- The indices
-
-