Class ClassView
java.lang.Object
org.datanucleus.store.rdbms.table.AbstractTable
org.datanucleus.store.rdbms.table.ViewImpl
org.datanucleus.store.rdbms.table.ClassView
- All Implemented Interfaces:
DatastoreClass
,Table
,org.datanucleus.store.schema.table.Table
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final org.datanucleus.metadata.ClassMetaData
Class MetaData for the class mapping to this view.private String
DDL statement for creating the viewprivate JavaTypeMapping[]
Mappings for the fields of this class to map to the View.private final org.datanucleus.util.MacroString
Definition of the view.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
ConstructorsConstructorDescriptionClassView
(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr, org.datanucleus.metadata.ClassMetaData cmd) Constructor for class view. -
Method Summary
Modifier and TypeMethodDescriptionAccessor for the base datastore class.getBaseDatastoreClassWithMember
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the base datastore class (table) managing the given field.final org.datanucleus.metadata.DiscriminatorMetaData
Accessor for Discriminator MetaDatagetExternalMapping
(org.datanucleus.metadata.AbstractMemberMetaData mmd, MappingType mappingType) Accessor for the external mapping for the specified member of the specified mapping type.org.datanucleus.metadata.AbstractMemberMetaData
getFieldMetaData
(String fieldName) Accessor for the MetaData for the named fieldorg.datanucleus.metadata.IdentityType
Accessor for the identity type in use.Accessor for a mapping for the ID.String[]
Accessor for the names of all classes managed by this table.getMemberMapping
(String fieldName) Accessor for the field mapping for the specified field name.getMemberMapping
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the mapping for the specified field/property.getMemberMappingInDatastoreClass
(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the mapping for the specified field only in this datastore class.org.datanucleus.metadata.AbstractMemberMetaData
getMetaDataForExternalMapping
(JavaTypeMapping mapping, MappingType mappingType) Accessor for the owner member metadata for the specified external mapping of the specified typeAccessor for any secondary tables for this table.getSQLCreateStatements
(Properties props) Method to return the necessary SQL create statements for this table.Accessor for the supertable for this table.getSurrogateColumn
(org.datanucleus.store.schema.table.SurrogateColumnType colType) getType()
Accessor for the type of the class being represented by this view.final org.datanucleus.metadata.VersionMetaData
Accessor for Version MetaDatavoid
initialize
(org.datanucleus.ClassLoaderResolver clr) Method to initialise the view.boolean
Accessor for whether this is a base datastore class (root in a hierarchy).boolean
Accessor for whether the object ID is attributed in the datastore.boolean
Accessor whether the supplied DatastoreClass is a supertable of this table.boolean
managesClass
(String className) Accessor for whether this table manages the specified classboolean
managesMapping
(JavaTypeMapping mapping) Convenience method to return if this table manages the columns for the supplied mapping.void
postInitialize
(org.datanucleus.ClassLoaderResolver clr) Post initialise.void
provideExternalMappings
(MappingConsumer consumer, MappingType mappingType) Instruction to provide all external mappings to the passed consumer.void
provideMappingsForMembers
(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] fieldNumbers, boolean includeSecondaryTables) Provide the mappings to the consumer for all specified members.void
provideNonPrimaryKeyMappings
(MappingConsumer consumer) Provide the mappings to the consumer for all non primary-key member mapped to this table.void
providePrimaryKeyMappings
(MappingConsumer consumer) Provide the mappings to the consumer for all primary-key member mapped to this table (for application identity).void
provideSurrogateMapping
(org.datanucleus.store.schema.table.SurrogateColumnType colType, MappingConsumer consumer) Provide the mapping for the specified surrogate column (if present).void
provideUnmappedColumns
(MappingConsumer consumer) Instruction to provide all columns without members in the class.Methods inherited from class org.datanucleus.store.rdbms.table.ViewImpl
addColumnInternal, getSQLDropStatements, validate
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumn, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getClassMetaData, getColumn, getColumnForName, getColumnForPosition, getColumns, getDatastoreIdentifierFullyQualified, getIdentifier, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getStoreManager, getSurrogateMapping, hasColumn, hasColumnName, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, preInitialize, tableExistsInDatastore, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.datanucleus.store.rdbms.table.DatastoreClass
toString
Methods inherited from interface org.datanucleus.store.rdbms.table.Table
addColumn, create, drop, exists, getColumn, getIdentifier, getStoreManager, getSurrogateMapping, hasColumn, isInitialized, isInitializedModified, isValidated, preInitialize, validate
Methods inherited from interface org.datanucleus.store.schema.table.Table
getCatalogName, getClassMetaData, getColumnForName, getColumnForPosition, getColumns, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName
-
Field Details
-
cmd
private final org.datanucleus.metadata.ClassMetaData cmdClass MetaData for the class mapping to this view. -
viewDef
private final org.datanucleus.util.MacroString viewDefDefinition of the view. -
createStatementDDL
DDL statement for creating the view -
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 viewcmd
- 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 interfaceTable
- 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 interfaceTable
- Overrides:
postInitialize
in classAbstractTable
- Parameters:
clr
- the ClassLoaderResolver
-
getIdMapping
Accessor for a mapping for the ID. A view row doesn't have an id as such.- Specified by:
getIdMapping
in interfaceTable
- 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 interfaceDatastoreClass
- Parameters:
mmd
- MetaData for the field- Returns:
- The base table.
-
getSuperDatastoreClass
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClass
in interfaceDatastoreClass
- Returns:
- The supertable
-
isSuperDatastoreClass
Accessor whether the supplied DatastoreClass is a supertable of this table.- Specified by:
isSuperDatastoreClass
in interfaceDatastoreClass
- Parameters:
table
- The DatastoreClass to check- Returns:
- Whether it is a supertable (somewhere up the inheritance tree)
-
getSecondaryDatastoreClasses
Accessor for any secondary tables for this table.- Specified by:
getSecondaryDatastoreClasses
in interfaceDatastoreClass
- Returns:
- Secondary tables (if any)
-
managesClass
Accessor for whether this table manages the specified class- Specified by:
managesClass
in interfaceDatastoreClass
- Parameters:
className
- Name of the class- Returns:
- Whether it is managed by this table
-
getManagedClasses
Description copied from interface:DatastoreClass
Accessor for the names of all classes managed by this table.- Specified by:
getManagedClasses
in interfaceDatastoreClass
- Returns:
- Names of the classes managed (stored) here
-
managesMapping
Convenience method to return if this table manages the columns for the supplied mapping.- Specified by:
managesMapping
in interfaceDatastoreClass
- Parameters:
mapping
- The mapping- Returns:
- Whether the mapping is managed in this table
-
getFieldMetaData
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 interfaceDatastoreClass
- 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 interfaceDatastoreClass
- Returns:
- Whether this is the base datastore class (table)
-
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 interfaceDatastoreClass
- 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 interfaceDatastoreClass
- 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 interfaceDatastoreClass
- Parameters:
colType
- Type of surrogate columnconsumer
- 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 interfaceDatastoreClass
- Parameters:
consumer
- Consumer for the mappingsfieldNumbers
- MetaData of the member to provide mappings forincludeSecondaryTables
- Whether to supply member in secondary tables
-
providePrimaryKeyMappings
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 interfaceDatastoreClass
- Parameters:
consumer
- Consumer for the mappings
-
provideNonPrimaryKeyMappings
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 interfaceDatastoreClass
- Parameters:
consumer
- Consumer for the mappings
-
provideExternalMappings
Description copied from interface:DatastoreClass
Instruction to provide all external mappings to the passed consumer.- Specified by:
provideExternalMappings
in interfaceDatastoreClass
- Parameters:
consumer
- The consumer for the mappingsmappingType
- Type of external mapping to provide
-
provideUnmappedColumns
Description copied from interface:DatastoreClass
Instruction to provide all columns without members in the class.- Specified by:
provideUnmappedColumns
in interfaceDatastoreClass
- Parameters:
consumer
- The consumer for the unmapped columns
-
getType
Accessor for the type of the class being represented by this view.- Specified by:
getType
in interfaceDatastoreClass
- Returns:
- The name of the class being represented here
-
getMemberMapping
Accessor for the mapping for the specified field/property.- Specified by:
getMemberMapping
in interfaceDatastoreClass
- Specified by:
getMemberMapping
in interfaceTable
- 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 interfaceDatastoreClass
- Parameters:
mmd
- Metadata of the field/property- Returns:
- The Mapping for the field (or null if not present here)
-
getMemberMapping
Accessor for the field mapping for the specified field name.- Specified by:
getMemberMapping
in interfaceDatastoreClass
- Parameters:
fieldName
- Name of the field- Returns:
- The Java type mapping for the field
-
getSQLCreateStatements
Method to return the necessary SQL create statements for this table.- Specified by:
getSQLCreateStatements
in classAbstractTable
- Parameters:
props
- Properties for controlling the creation of views- Returns:
- The SQL create statements.
-
getSurrogateColumn
- Specified by:
getSurrogateColumn
in interfaceorg.datanucleus.store.schema.table.Table
- Overrides:
getSurrogateColumn
in classAbstractTable
-
getDiscriminatorMetaData
public final org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()Accessor for Discriminator MetaData- Specified by:
getDiscriminatorMetaData
in interfaceTable
- Overrides:
getDiscriminatorMetaData
in classAbstractTable
- Returns:
- Returns the Discriminator MetaData.
-
getVersionMetaData
public final org.datanucleus.metadata.VersionMetaData getVersionMetaData()Accessor for Version MetaData- Specified by:
getVersionMetaData
in interfaceTable
- Overrides:
getVersionMetaData
in classAbstractTable
- 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 interfaceDatastoreClass
- Parameters:
mmd
- MetaData for the (external) membermappingType
- 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 interfaceDatastoreClass
- Parameters:
mapping
- The external mappingmappingType
- The type of mapping- Returns:
- Member MetaData in the owner class
-