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.ClassMetaDataClass MetaData for the class mapping to this view.private StringDDL statement for creating the viewprivate JavaTypeMapping[]Mappings for the fields of this class to map to the View.private final org.datanucleus.util.MacroStringDefinition of the view.Fields inherited from class 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.DiscriminatorMetaDataAccessor 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.AbstractMemberMetaDatagetFieldMetaData(String fieldName) Accessor for the MetaData for the named fieldorg.datanucleus.metadata.IdentityTypeAccessor 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.AbstractMemberMetaDatagetMetaDataForExternalMapping(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.VersionMetaDataAccessor for Version MetaDatavoidinitialize(org.datanucleus.ClassLoaderResolver clr) Method to initialise the view.booleanAccessor for whether this is a base datastore class (root in a hierarchy).booleanAccessor for whether the object ID is attributed in the datastore.booleanAccessor 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 ViewImpl
addColumnInternal, getSQLDropStatements, validateMethods inherited from class 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, toStringMethods inherited from interface DatastoreClass
toStringMethods inherited from interface Table
addColumn, create, drop, exists, getColumn, getIdentifier, getStoreManager, getSurrogateMapping, hasColumn, isInitialized, isInitializedModified, isValidated, preInitialize, validateMethods 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:
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
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
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClassin interfaceDatastoreClass- Returns:
- The supertable
-
isSuperDatastoreClass
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
Accessor for any secondary tables for this table.- Specified by:
getSecondaryDatastoreClassesin interfaceDatastoreClass- Returns:
- Secondary tables (if any)
-
managesClass
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
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
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
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
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
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
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
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
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
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
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
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
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
- 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
-