Class SecondaryTable

All Implemented Interfaces:
DatastoreClass, SecondaryDatastoreClass, Table, org.datanucleus.store.schema.table.Table

public class SecondaryTable extends AbstractClassTable implements SecondaryDatastoreClass
Representation of a secondary table for a class. Has a primary table that manages the main fields for that class and some fields are defined (using <field table="...">) to be stored in the secondary table. Many of the methods in this class defer to the equivalent method in the primary table.
  • Field Details

    • primaryTable

      private ClassTable primaryTable
      Primary table
    • joinMetaData

      private org.datanucleus.metadata.JoinMetaData joinMetaData
      MetaData for the join to the primary table.
  • Constructor Details

    • SecondaryTable

      SecondaryTable(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr, ClassTable primaryTable, org.datanucleus.metadata.JoinMetaData jmd, org.datanucleus.ClassLoaderResolver clr)
      Constructor. This is package level so that it SecondaryTables are only created by other tables.
      Parameters:
      tableName - Table name SQL identifier
      storeMgr - Store Manager to manage this table
      primaryTable - The primary table for the class
      jmd - MetaData for the join to the primary table
      clr - The ClassLoaderResolver
  • Method Details

    • preInitialize

      public void preInitialize(org.datanucleus.ClassLoaderResolver clr)
      Pre initilize. For things that must be initialized right after constructor
      Specified by:
      preInitialize in interface Table
      Overrides:
      preInitialize in class AbstractTable
      Parameters:
      clr - the ClassLoaderResolver
    • initialize

      public void initialize(org.datanucleus.ClassLoaderResolver clr)
      Method to initialise the table. This will initialise the primary key columns for the table. Any other columns are added via the addFieldMapping() method.
      Specified by:
      initialize in interface Table
      Parameters:
      clr - The ClassLoaderResolver
    • postInitialize

      public void postInitialize(org.datanucleus.ClassLoaderResolver clr)
      Post initilize. For things that must be set after all classes have been initialized before
      Specified by:
      postInitialize in interface Table
      Overrides:
      postInitialize in class AbstractTable
      Parameters:
      clr - the ClassLoaderResolver
    • initializePK

      protected void initializePK(org.datanucleus.ClassLoaderResolver clr)
      Method to initialise the primary key of this table.
      Specified by:
      initializePK in class AbstractClassTable
      Parameters:
      clr - The ClassLoaderResolver
      See Also:
    • getPrimaryKey

      public PrimaryKey getPrimaryKey()
      Accessor for the primary key for this table. Overrides the method in TableImpl to add on any specification of PK name in the metadata.
      Overrides:
      getPrimaryKey in class TableImpl
      Returns:
      The primary key.
    • getPrimaryDatastoreClass

      public DatastoreClass getPrimaryDatastoreClass()
      Accessor for the primary datastore class that this is dependent on.
      Specified by:
      getPrimaryDatastoreClass in interface SecondaryDatastoreClass
      Returns:
      The associated primary datastore class.
    • getJoinMetaData

      public org.datanucleus.metadata.JoinMetaData getJoinMetaData()
      Accessor for the JoinMetaData which is used to join to the primary DatastoreClass.
      Specified by:
      getJoinMetaData in interface SecondaryDatastoreClass
      Returns:
      JoinMetaData
    • getIdentityType

      public org.datanucleus.metadata.IdentityType getIdentityType()
      Accessor for the identity-type. Simply returns the same as the primary table
      Specified by:
      getIdentityType in interface DatastoreClass
      Specified by:
      getIdentityType in class AbstractClassTable
      Returns:
      identity-type tag value
    • getType

      public String getType()
      Accessor for the main type represented here.
      Specified by:
      getType in interface DatastoreClass
      Returns:
      Name of the principal class represented
    • isObjectIdDatastoreAttributed

      public boolean isObjectIdDatastoreAttributed()
      Whether this table or super table has id (primary key) attributed by the datastore
      Specified by:
      isObjectIdDatastoreAttributed in interface DatastoreClass
      Specified by:
      isObjectIdDatastoreAttributed in class AbstractClassTable
      Returns:
      true if the id attributed by the datastore
    • isBaseDatastoreClass

      public boolean isBaseDatastoreClass()
      Whether this table is the base in the inheritance hierarchy.
      Specified by:
      isBaseDatastoreClass in interface DatastoreClass
      Returns:
      true if this table is a root table
    • getBaseDatastoreClass

      public DatastoreClass getBaseDatastoreClass()
      Description copied from interface: DatastoreClass
      Accessor for the base datastore class. Returns this object if it has no superclass table, otherwise goes up to the superclass etc.
      Specified by:
      getBaseDatastoreClass in interface DatastoreClass
      Returns:
      The base datastore class
    • getBaseDatastoreClassWithMember

      public DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
      Convenience accessor for the base table for this table which has the specified member.
      Specified by:
      getBaseDatastoreClassWithMember in interface DatastoreClass
      Parameters:
      mmd - MetaData for this member
      Returns:
      The base table which has the member specified
    • getSuperDatastoreClass

      public DatastoreClass getSuperDatastoreClass()
      Accessor for the supertable for this table.
      Specified by:
      getSuperDatastoreClass in interface DatastoreClass
      Returns:
      The supertable
    • isSuperDatastoreClass

      public boolean isSuperDatastoreClass(DatastoreClass table)
      Accessor whether the supplied DatastoreClass is a supertable of this table.
      Specified by:
      isSuperDatastoreClass in interface DatastoreClass
      Parameters:
      table - The DatastoreClass to check
      Returns:
      Whether it is a supertable (somewhere up the inheritance tree)
    • getSecondaryDatastoreClasses

      public Collection<? extends SecondaryDatastoreClass> getSecondaryDatastoreClasses()
      Description copied from interface: DatastoreClass
      Accessor for any secondary tables for this table.
      Specified by:
      getSecondaryDatastoreClasses in interface DatastoreClass
      Returns:
      Collection of secondary tables (if any)
    • managesClass

      public boolean managesClass(String className)
      Accessor for whether this table manages the specified class.
      Specified by:
      managesClass in interface DatastoreClass
      Parameters:
      className - Name of the class
      Returns:
      Whether it is managed by this table
    • getManagedClasses

      public String[] getManagedClasses()
      Description copied from interface: DatastoreClass
      Accessor for the names of all classes managed by this table.
      Specified by:
      getManagedClasses in interface DatastoreClass
      Returns:
      Names of the classes managed (stored) here
    • 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 - ClassLoader resolver
      Returns:
      The expected foreign keys.
    • getMemberMapping

      public JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
      Accessor for the member Mapping. Returns the mapping if it is present in this table.
      Specified by:
      getMemberMapping in interface DatastoreClass
      Specified by:
      getMemberMapping in interface Table
      Parameters:
      mmd - MetaData for this member
      Returns:
      the Mapping for the member
    • getMemberMappingInDatastoreClass

      public JavaTypeMapping getMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)
      Accessor for the mapping for the specified member only in this datastore class.
      Specified by:
      getMemberMappingInDatastoreClass in interface DatastoreClass
      Parameters:
      mmd - Metadata of the member
      Returns:
      The Mapping for the member (or null if not present here)
    • getMemberMapping

      public JavaTypeMapping getMemberMapping(String memberName)
      Accessor for the mapping for the specified member. TODO Use of this is discouraged since the memberName is not fully qualified and if a superclass-table inheritance is used we could have 2 members of that name here.
      Specified by:
      getMemberMapping in interface DatastoreClass
      Parameters:
      memberName - Name of the member
      Returns:
      The mapping for the member
    • getIdMapping

      public JavaTypeMapping getIdMapping()
      Accessor for the ID mapping for this table.
      Specified by:
      getIdMapping in interface Table
      Returns:
      The ID mapping
    • providePrimaryKeyMappings

      public void providePrimaryKeyMappings(MappingConsumer consumer)
      Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).
      Specified by:
      providePrimaryKeyMappings in interface DatastoreClass
      Specified by:
      providePrimaryKeyMappings in class AbstractClassTable
      Parameters:
      consumer - Consumer for the mappings
    • provideExternalMappings

      public void provideExternalMappings(MappingConsumer consumer, MappingType mappingType)
      Description copied from interface: DatastoreClass
      Instruction to provide all external mappings to the passed consumer.
      Specified by:
      provideExternalMappings in interface DatastoreClass
      Parameters:
      consumer - The consumer for the mappings
      mappingType - Type of external mapping to provide
    • provideUnmappedColumns

      public void provideUnmappedColumns(MappingConsumer consumer)
      Method to provide all unmapped columns to the consumer.
      Specified by:
      provideUnmappedColumns in interface DatastoreClass
      Parameters:
      consumer - Consumer of information
    • getExternalMapping

      public JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, MappingType mappingType)
      Description copied from interface: DatastoreClass
      Accessor for the external mapping for the specified member of the specified mapping type. An external mapping is a mapping for which there is no member in the actual class to represent it (part of a relation). The type can be FK, FK discriminator, order, etc
      Specified by:
      getExternalMapping in interface DatastoreClass
      Parameters:
      fmd - MetaData for the (external) member
      mappingType - The type of mapping
      Returns:
      The external mapping
    • getMetaDataForExternalMapping

      public org.datanucleus.metadata.AbstractMemberMetaData getMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType)
      Description copied from interface: DatastoreClass
      Accessor for the owner member metadata for the specified external mapping of the specified type
      Specified by:
      getMetaDataForExternalMapping in interface DatastoreClass
      Parameters:
      mapping - The external mapping
      mappingType - The type of mapping
      Returns:
      Member MetaData in the owner class