Class 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 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 member
        tableName - Identifier name of this table
        mmd - MetaData for the member 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 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 table
        autoMode - 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 table
        autoMode - 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 class TableImpl
        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 class TableImpl
        Parameters:
        clr - The ClassLoaderResolver
        Returns:
        The indices