Interface Table

All Superinterfaces:
org.datanucleus.store.schema.table.Table
All Known Subinterfaces:
DatastoreClass, SecondaryDatastoreClass
All Known Implementing Classes:
AbstractClassTable, AbstractTable, ArrayTable, ClassTable, ClassView, CollectionTable, ElementContainerTable, JoinTable, MapTable, PersistableJoinTable, ProbeTable, SchemaTable, SecondaryTable, SequenceTable, TableImpl, ViewImpl

public interface Table extends org.datanucleus.store.schema.table.Table
Representation of a table in an RDBMS.

There are 2 aspects to a table. The first is the internal representation, provided here. This has a state. The second aspect to the table is its external (datastore) representation. This reflects whether it exists, or whether it has been deleted, etc.

This interface provides some methods for mapping from the internal representation to the external representation. These are the methods

  • create() - to create the table in the datastore
  • drop() - to drop the table from the datastore
  • validate() - to compare the internal and external representations.
  • exists() - whether the external representation exists
  • Method Summary

    Modifier and Type
    Method
    Description
    addColumn(String storedJavaType, DatastoreIdentifier name, JavaTypeMapping mapping, org.datanucleus.metadata.ColumnMetaData colmd)
    Method to add a new column to the internal representation.
    boolean
    Method to create the table in the datastore representation.
    void
    Method to drop the table from the datastore representation.
    boolean
    exists(Connection conn, boolean create)
    Accessor for whether the table exists in the datastore.
    Accessor for the column with the specified identifier.
    org.datanucleus.metadata.DiscriminatorMetaData
    Accessor for Discriminator MetaData.
    Accessor for the identifier for this object.
    Accessor for the ID mapping of this container object.
    getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
    Accessor for the mapping for the specified FieldMetaData.
     
    getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses)
    Accessor for the mapping for the specified surrogate type.
    org.datanucleus.metadata.VersionMetaData
    Accessor for the Version MetaData.
    boolean
    Checks if there is a column for the identifier
    void
    initialize(org.datanucleus.ClassLoaderResolver clr)
    Method to initialise the table.
    boolean
    Accessor for whether the table has been initialised.
    boolean
    Accessor for whether the table has been modified after being initialised.
    boolean
    Accessor for whether the table is validated.
    void
    postInitialize(org.datanucleus.ClassLoaderResolver clr)
    Post-initialize; for things that must be set after all classes have been initialized.
    void
    preInitialize(org.datanucleus.ClassLoaderResolver clr)
    Pre-initialize method; for things that must be initialized right after construction.
    boolean
    validate(Connection conn, boolean validateColumnStructure, boolean autoCreate, Collection<Throwable> autoCreateErrors)
    Method to validate the table against what is in the datastore.

    Methods inherited from interface org.datanucleus.store.schema.table.Table

    getCatalogName, getClassMetaData, getColumnForName, getColumnForPosition, getColumns, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getSurrogateColumn
  • Method Details

    • getStoreManager

      RDBMSStoreManager getStoreManager()
      Specified by:
      getStoreManager in interface org.datanucleus.store.schema.table.Table
    • getIdentifier

      DatastoreIdentifier getIdentifier()
      Accessor for the identifier for this object.
      Returns:
      The identifier.
    • addColumn

      Column addColumn(String storedJavaType, DatastoreIdentifier name, JavaTypeMapping mapping, org.datanucleus.metadata.ColumnMetaData colmd)
      Method to add a new column to the internal representation.
      Parameters:
      storedJavaType - The type of the Java field to store
      name - The name of the column
      mapping - The type mapping for this column
      colmd - The column MetaData
      Returns:
      The new Column
    • hasColumn

      boolean hasColumn(DatastoreIdentifier identifier)
      Checks if there is a column for the identifier
      Parameters:
      identifier - the identifier of the column
      Returns:
      true if the column exists for the identifier
    • getColumn

      Column getColumn(DatastoreIdentifier identifier)
      Accessor for the column with the specified identifier. Returns null if has no column of this name.
      Parameters:
      identifier - The name of the column
      Returns:
      The column
    • getIdMapping

      JavaTypeMapping getIdMapping()
      Accessor for the ID mapping of this container object.
      Returns:
      The ID Mapping (if present)
    • getMemberMapping

      JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
      Accessor for the mapping for the specified FieldMetaData. A datastore container object may store many fields.
      Parameters:
      mmd - Metadata for the field/property
      Returns:
      The Mapping for the member, or null if the FieldMetaData cannot be found
    • getSurrogateMapping

      JavaTypeMapping getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses)
      Accessor for the mapping for the specified surrogate type.
      Parameters:
      colType - Column type for the surrogate
      allowSuperclasses - Whether to allow searching superclasses when not specified in this table.
      Returns:
      The mapping
    • getDiscriminatorMetaData

      org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
      Accessor for Discriminator MetaData.
      Returns:
      Returns the Discriminator MetaData.
    • getVersionMetaData

      org.datanucleus.metadata.VersionMetaData getVersionMetaData()
      Accessor for the Version MetaData.
      Returns:
      Returns the Version MetaData.
    • preInitialize

      void preInitialize(org.datanucleus.ClassLoaderResolver clr)
      Pre-initialize method; for things that must be initialized right after construction.
      Parameters:
      clr - the ClassLoaderResolver
    • initialize

      void initialize(org.datanucleus.ClassLoaderResolver clr)
      Method to initialise the table.
      Parameters:
      clr - The ClassLoaderResolver
    • postInitialize

      void postInitialize(org.datanucleus.ClassLoaderResolver clr)
      Post-initialize; for things that must be set after all classes have been initialized.
      Parameters:
      clr - the ClassLoaderResolver
    • isInitialized

      boolean isInitialized()
      Accessor for whether the table has been initialised.
      Returns:
      Whether it is initialised.
    • isInitializedModified

      boolean isInitializedModified()
      Accessor for whether the table has been modified after being initialised.
      Returns:
      Whether it has been modified after being initialised.
    • validate

      boolean validate(Connection conn, boolean validateColumnStructure, boolean autoCreate, Collection<Throwable> autoCreateErrors) throws SQLException
      Method to validate the table against what is in the datastore.
      Parameters:
      conn - The connection
      validateColumnStructure - Whether to validate down to the column structure, or just the existence
      autoCreate - Whether to update the table to fix any errors.
      autoCreateErrors - Errors found during the auto-create process
      Returns:
      Whether it validates successfully
      Throws:
      SQLException - Thrown if an error occurrs in the validation
    • isValidated

      boolean isValidated()
      Accessor for whether the table is validated.
      Returns:
      Whether it is validated.
    • exists

      boolean exists(Connection conn, boolean create) throws SQLException
      Accessor for whether the table exists in the datastore. Will throw a MissingTableException if the table doesn't exist.
      Parameters:
      conn - The connecton to use to verify it
      create - Whether to create it if it doesn't exist
      Returns:
      Whether the table was added.
      Throws:
      SQLException - Thrown if an error occurs in the check
    • create

      boolean create(Connection conn) throws SQLException
      Method to create the table in the datastore representation.
      Parameters:
      conn - The connection to use
      Returns:
      true if the table was created
      Throws:
      SQLException - Thrown if an error occurs creating the table.
    • drop

      void drop(Connection conn) throws SQLException
      Method to drop the table from the datastore representation.
      Parameters:
      conn - The connection to use
      Throws:
      SQLException - Thrown if an error occurs