Class ClassView

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

public class ClassView extends ViewImpl implements DatastoreClass
Representation of an SQL View for a Class. Requires that the class use "nondurable" identity. Since a view is read-only, many methods throw exceptions that the operation is not supported.
  • Field Details

    • cmd

      private final org.datanucleus.metadata.ClassMetaData cmd
      Class MetaData for the class mapping to this view.
    • viewDef

      private final org.datanucleus.util.MacroString viewDef
      Definition of the view.
    • createStatementDDL

      private String createStatementDDL
      DDL statement for creating the view
    • fieldMappings

      private JavaTypeMapping[] fieldMappings
      Mappings for the fields of this class to map to the View.
  • Constructor Details

    • ClassView

      public ClassView(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr, org.datanucleus.metadata.ClassMetaData cmd)
      Constructor for class view.
      Parameters:
      tableName - The name of the view.
      storeMgr - The RDBMS manager managing this view
      cmd - The metadata for the class represented by this view.
  • Method Details

    • initialize

      public void initialize(org.datanucleus.ClassLoaderResolver clr)
      Method to initialise the view. Generates the mappings for all fields in the class to map to this view.
      Specified by:
      initialize in interface Table
      Parameters:
      clr - The ClassLoaderResolver
    • postInitialize

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

      public JavaTypeMapping getIdMapping()
      Accessor for a mapping for the ID. A view row doesn't have an id as such.
      Specified by:
      getIdMapping in interface Table
      Returns:
      The ID mapping.
    • getBaseDatastoreClassWithMember

      public DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
      Accessor for the base datastore class (table) managing the given field. Returns null since we don't manage things the same with views.
      Specified by:
      getBaseDatastoreClassWithMember in interface DatastoreClass
      Parameters:
      mmd - MetaData for the field
      Returns:
      The base table.
    • 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 getSecondaryDatastoreClasses()
      Accessor for any secondary tables for this table.
      Specified by:
      getSecondaryDatastoreClasses in interface DatastoreClass
      Returns:
      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
    • managesMapping

      public boolean managesMapping(JavaTypeMapping mapping)
      Convenience method to return if this table manages the columns for the supplied mapping.
      Specified by:
      managesMapping in interface DatastoreClass
      Parameters:
      mapping - The mapping
      Returns:
      Whether the mapping is managed in this table
    • getFieldMetaData

      public org.datanucleus.metadata.AbstractMemberMetaData getFieldMetaData(String fieldName)
      Accessor for the MetaData for the named field
      Parameters:
      fieldName - Name of the field
      Returns:
      MetaData for the field
    • getIdentityType

      public org.datanucleus.metadata.IdentityType getIdentityType()
      Accessor for the identity type in use.
      Specified by:
      getIdentityType in interface DatastoreClass
      Returns:
      The identity type
    • isBaseDatastoreClass

      public boolean isBaseDatastoreClass()
      Accessor for whether this is a base datastore class (root in a hierarchy). Returns true since we dont use inheritance in views.
      Specified by:
      isBaseDatastoreClass in interface DatastoreClass
      Returns:
      Whether this is the base datastore class (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
    • isObjectIdDatastoreAttributed

      public boolean isObjectIdDatastoreAttributed()
      Accessor for whether the object ID is attributed in the datastore. Returns false since we dont use such things on views.
      Specified by:
      isObjectIdDatastoreAttributed in interface DatastoreClass
      Returns:
      Whether it is attributed in the datastore.
    • provideSurrogateMapping

      public void provideSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, MappingConsumer consumer)
      Description copied from interface: DatastoreClass
      Provide the mapping for the specified surrogate column (if present). This can be datastore id, discriminator, version, multitenancy, soft-delete, etc.
      Specified by:
      provideSurrogateMapping in interface DatastoreClass
      Parameters:
      colType - Type of surrogate column
      consumer - The consumer for the mapping
    • provideMappingsForMembers

      public void provideMappingsForMembers(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] fieldNumbers, boolean includeSecondaryTables)
      Description copied from interface: DatastoreClass
      Provide the mappings to the consumer for all specified members.
      Specified by:
      provideMappingsForMembers in interface DatastoreClass
      Parameters:
      consumer - Consumer for the mappings
      fieldNumbers - MetaData of the member to provide mappings for
      includeSecondaryTables - Whether to supply member in secondary tables
    • providePrimaryKeyMappings

      public void providePrimaryKeyMappings(MappingConsumer consumer)
      Description copied from interface: DatastoreClass
      Provide the mappings to the consumer for all primary-key member mapped to this table (for application identity).
      Specified by:
      providePrimaryKeyMappings in interface DatastoreClass
      Parameters:
      consumer - Consumer for the mappings
    • provideNonPrimaryKeyMappings

      public void provideNonPrimaryKeyMappings(MappingConsumer consumer)
      Description copied from interface: DatastoreClass
      Provide the mappings to the consumer for all non primary-key member mapped to this table.
      Specified by:
      provideNonPrimaryKeyMappings in interface DatastoreClass
      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)
      Description copied from interface: DatastoreClass
      Instruction to provide all columns without members in the class.
      Specified by:
      provideUnmappedColumns in interface DatastoreClass
      Parameters:
      consumer - The consumer for the unmapped columns
    • getType

      public String getType()
      Accessor for the type of the class being represented by this view.
      Specified by:
      getType in interface DatastoreClass
      Returns:
      The name of the class being represented here
    • getMemberMapping

      public JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
      Accessor for the mapping for the specified field/property.
      Specified by:
      getMemberMapping in interface DatastoreClass
      Specified by:
      getMemberMapping in interface Table
      Parameters:
      mmd - Metadata for the field/property
      Returns:
      The Mapping for the field.
    • getMemberMappingInDatastoreClass

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

      public JavaTypeMapping getMemberMapping(String fieldName)
      Accessor for the field mapping for the specified field name.
      Specified by:
      getMemberMapping in interface DatastoreClass
      Parameters:
      fieldName - Name of the field
      Returns:
      The Java type mapping for the field
    • getSQLCreateStatements

      protected List<String> getSQLCreateStatements(Properties props)
      Method to return the necessary SQL create statements for this table.
      Specified by:
      getSQLCreateStatements in class AbstractTable
      Parameters:
      props - Properties for controlling the creation of views
      Returns:
      The SQL create statements.
    • getSurrogateColumn

      public Column getSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType)
      Specified by:
      getSurrogateColumn in interface org.datanucleus.store.schema.table.Table
      Overrides:
      getSurrogateColumn in class AbstractTable
    • getDiscriminatorMetaData

      public final org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
      Accessor for Discriminator MetaData
      Specified by:
      getDiscriminatorMetaData in interface Table
      Overrides:
      getDiscriminatorMetaData in class AbstractTable
      Returns:
      Returns the Discriminator MetaData.
    • getVersionMetaData

      public final org.datanucleus.metadata.VersionMetaData getVersionMetaData()
      Accessor for Version MetaData
      Specified by:
      getVersionMetaData in interface Table
      Overrides:
      getVersionMetaData in class AbstractTable
      Returns:
      Returns the Version MetaData.
    • getExternalMapping

      public JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd, 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:
      mmd - 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