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 DatastoreClassgetBaseDatastoreClass()Accessor for the base datastore class.DatastoreClassgetBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)Accessor for the base datastore class (table) managing the given field.org.datanucleus.metadata.DiscriminatorMetaDatagetDiscriminatorMetaData()Accessor for Discriminator MetaDataJavaTypeMappinggetExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd, MappingType mappingType)Accessor for the external mapping for the specified member of the specified mapping type.org.datanucleus.metadata.AbstractMemberMetaDatagetFieldMetaData(String fieldName)Accessor for the MetaData for the named fieldorg.datanucleus.metadata.IdentityTypegetIdentityType()Accessor for the identity type in use.JavaTypeMappinggetIdMapping()Accessor for a mapping for the ID.String[]getManagedClasses()Accessor for the names of all classes managed by this table.JavaTypeMappinggetMemberMapping(String fieldName)Accessor for the field mapping for the specified field name.JavaTypeMappinggetMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)Accessor for the mapping for the specified field/property.JavaTypeMappinggetMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)Accessor for the mapping for the specified field only in this datastore class.org.datanucleus.metadata.AbstractMemberMetaDatagetMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType)Accessor for the owner member metadata for the specified external mapping of the specified typeCollectiongetSecondaryDatastoreClasses()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.DatastoreClassgetSuperDatastoreClass()Accessor for the supertable for this table.ColumngetSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType)StringgetType()Accessor for the type of the class being represented by this view.org.datanucleus.metadata.VersionMetaDatagetVersionMetaData()Accessor for Version MetaDatavoidinitialize(org.datanucleus.ClassLoaderResolver clr)Method to initialise the view.booleanisBaseDatastoreClass()Accessor for whether this is a base datastore class (root in a hierarchy).booleanisObjectIdDatastoreAttributed()Accessor for whether the object ID is attributed in the datastore.booleanisSuperDatastoreClass(DatastoreClass table)Accessor whether the supplied DatastoreClass is a supertable of this table.booleanmanagesClass(String className)Accessor for whether this table manages the specified classbooleanmanagesMapping(JavaTypeMapping mapping)Convenience method to return if this table manages the columns for the supplied mapping.voidpostInitialize(org.datanucleus.ClassLoaderResolver clr)Post initialise.voidprovideExternalMappings(MappingConsumer consumer, MappingType mappingType)Instruction to provide all external mappings to the passed consumer.voidprovideMappingsForMembers(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] fieldNumbers, boolean includeSecondaryTables)Provide the mappings to the consumer for all specified members.voidprovideNonPrimaryKeyMappings(MappingConsumer consumer)Provide the mappings to the consumer for all non primary-key member mapped to this table.voidprovidePrimaryKeyMappings(MappingConsumer consumer)Provide the mappings to the consumer for all primary-key member mapped to this table (for application identity).voidprovideSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, MappingConsumer consumer)Provide the mapping for the specified surrogate column (if present).voidprovideUnmappedColumns(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:
initializein 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:
postInitializein interfaceTable- Overrides:
postInitializein 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:
getIdMappingin 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:
getBaseDatastoreClassWithMemberin interfaceDatastoreClass- Parameters:
mmd- MetaData for the field- Returns:
- The base table.
-
getSuperDatastoreClass
public DatastoreClass getSuperDatastoreClass()
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClassin interfaceDatastoreClass- Returns:
- The supertable
-
isSuperDatastoreClass
public boolean isSuperDatastoreClass(DatastoreClass table)
Accessor whether the supplied DatastoreClass is a supertable of this table.- Specified by:
isSuperDatastoreClassin 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:
getSecondaryDatastoreClassesin interfaceDatastoreClass- Returns:
- Secondary tables (if any)
-
managesClass
public boolean managesClass(String className)
Accessor for whether this table manages the specified class- Specified by:
managesClassin interfaceDatastoreClass- Parameters:
className- Name of the class- Returns:
- Whether it is managed by this table
-
getManagedClasses
public String[] getManagedClasses()
Description copied from interface:DatastoreClassAccessor for the names of all classes managed by this table.- Specified by:
getManagedClassesin 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:
managesMappingin 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:
getIdentityTypein 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:
isBaseDatastoreClassin interfaceDatastoreClass- Returns:
- Whether this is the base datastore class (table)
-
getBaseDatastoreClass
public DatastoreClass getBaseDatastoreClass()
Description copied from interface:DatastoreClassAccessor for the base datastore class. Returns this object if it has no superclass table, otherwise goes up to the superclass etc.- Specified by:
getBaseDatastoreClassin 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:
isObjectIdDatastoreAttributedin 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:DatastoreClassProvide the mapping for the specified surrogate column (if present). This can be datastore id, discriminator, version, multitenancy, soft-delete, etc.- Specified by:
provideSurrogateMappingin 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:DatastoreClassProvide the mappings to the consumer for all specified members.- Specified by:
provideMappingsForMembersin 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:DatastoreClassProvide the mappings to the consumer for all primary-key member mapped to this table (for application identity).- Specified by:
providePrimaryKeyMappingsin interfaceDatastoreClass- Parameters:
consumer- Consumer for the mappings
-
provideNonPrimaryKeyMappings
public void provideNonPrimaryKeyMappings(MappingConsumer consumer)
Description copied from interface:DatastoreClassProvide the mappings to the consumer for all non primary-key member mapped to this table.- Specified by:
provideNonPrimaryKeyMappingsin interfaceDatastoreClass- Parameters:
consumer- Consumer for the mappings
-
provideExternalMappings
public void provideExternalMappings(MappingConsumer consumer, MappingType mappingType)
Description copied from interface:DatastoreClassInstruction to provide all external mappings to the passed consumer.- Specified by:
provideExternalMappingsin interfaceDatastoreClass- Parameters:
consumer- The consumer for the mappingsmappingType- Type of external mapping to provide
-
provideUnmappedColumns
public void provideUnmappedColumns(MappingConsumer consumer)
Description copied from interface:DatastoreClassInstruction to provide all columns without members in the class.- Specified by:
provideUnmappedColumnsin 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:
getTypein 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:
getMemberMappingin interfaceDatastoreClass- Specified by:
getMemberMappingin 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:
getMemberMappingInDatastoreClassin 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:
getMemberMappingin 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:
getSQLCreateStatementsin 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:
getSurrogateColumnin interfaceorg.datanucleus.store.schema.table.Table- Overrides:
getSurrogateColumnin classAbstractTable
-
getDiscriminatorMetaData
public final org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
Accessor for Discriminator MetaData- Specified by:
getDiscriminatorMetaDatain interfaceTable- Overrides:
getDiscriminatorMetaDatain classAbstractTable- Returns:
- Returns the Discriminator MetaData.
-
getVersionMetaData
public final org.datanucleus.metadata.VersionMetaData getVersionMetaData()
Accessor for Version MetaData- Specified by:
getVersionMetaDatain interfaceTable- Overrides:
getVersionMetaDatain classAbstractTable- Returns:
- Returns the Version MetaData.
-
getExternalMapping
public JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd, MappingType mappingType)
Description copied from interface:DatastoreClassAccessor 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:
getExternalMappingin 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:DatastoreClassAccessor for the owner member metadata for the specified external mapping of the specified type- Specified by:
getMetaDataForExternalMappingin interfaceDatastoreClass- Parameters:
mapping- The external mappingmappingType- The type of mapping- Returns:
- Member MetaData in the owner class
-
-