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
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 Summary
-
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
Constructors Constructor Description ClassView(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr, org.datanucleus.metadata.ClassMetaData cmd)
Constructor for class view.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DatastoreClass
getBaseDatastoreClass()
Accessor for the base datastore class.DatastoreClass
getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the base datastore class (table) managing the given field.org.datanucleus.metadata.DiscriminatorMetaData
getDiscriminatorMetaData()
Accessor for Discriminator MetaDataJavaTypeMapping
getExternalMapping(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
getIdentityType()
Accessor for the identity type in use.JavaTypeMapping
getIdMapping()
Accessor for a mapping for the ID.String[]
getManagedClasses()
Accessor for the names of all classes managed by this table.JavaTypeMapping
getMemberMapping(String fieldName)
Accessor for the field mapping for the specified field name.JavaTypeMapping
getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the mapping for the specified field/property.JavaTypeMapping
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 typeCollection
getSecondaryDatastoreClasses()
Accessor for any secondary tables for this table.protected List<String>
getSQLCreateStatements(Properties props)
Method to return the necessary SQL create statements for this table.DatastoreClass
getSuperDatastoreClass()
Accessor for the supertable for this table.Column
getSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType)
String
getType()
Accessor for the type of the class being represented by this view.org.datanucleus.metadata.VersionMetaData
getVersionMetaData()
Accessor for Version MetaDatavoid
initialize(org.datanucleus.ClassLoaderResolver clr)
Method to initialise the view.boolean
isBaseDatastoreClass()
Accessor for whether this is a base datastore class (root in a hierarchy).boolean
isObjectIdDatastoreAttributed()
Accessor for whether the object ID is attributed in the datastore.boolean
isSuperDatastoreClass(DatastoreClass table)
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
-
-
-
-
Constructor Detail
-
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 Detail
-
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
public JavaTypeMapping 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
public DatastoreClass getSuperDatastoreClass()
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClass
in interfaceDatastoreClass
- Returns:
- The supertable
-
isSuperDatastoreClass
public boolean isSuperDatastoreClass(DatastoreClass table)
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
public Collection getSecondaryDatastoreClasses()
Accessor for any secondary tables for this table.- Specified by:
getSecondaryDatastoreClasses
in interfaceDatastoreClass
- Returns:
- Secondary tables (if any)
-
managesClass
public boolean managesClass(String className)
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
public String[] 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
public boolean managesMapping(JavaTypeMapping mapping)
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
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 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
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 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
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 interfaceDatastoreClass
- 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 interfaceDatastoreClass
- 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 interfaceDatastoreClass
- Parameters:
consumer
- The consumer for the mappingsmappingType
- 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 interfaceDatastoreClass
- 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 interfaceDatastoreClass
- 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 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
public JavaTypeMapping getMemberMapping(String fieldName)
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
protected List<String> getSQLCreateStatements(Properties props)
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
public Column getSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType)
- 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
-
-