org.datanucleus.store.rdbms.table
Class ClassView

java.lang.Object
  extended by org.datanucleus.store.rdbms.table.AbstractTable
      extended by org.datanucleus.store.rdbms.table.ViewImpl
          extended by org.datanucleus.store.rdbms.table.ClassView
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreClass, org.datanucleus.store.mapped.DatastoreContainerObject, Table

public class ClassView
extends ViewImpl
implements org.datanucleus.store.mapped.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.

Version:
$Revision: 1.43 $

Field Summary
 
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByName, dba, existsInDatastore, identifier, LOCALISER, state, storeMgr
 
Constructor Summary
ClassView(org.datanucleus.store.mapped.DatastoreIdentifier tableName, RDBMSManager storeMgr, org.datanucleus.metadata.ClassMetaData cmd)
          Constructor for class view.
 
Method Summary
 org.datanucleus.store.mapped.DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          Accessor for the base datastore class (table) managing the given field.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getDataStoreObjectIdMapping()
          Accessor for the datastore identity id mapping.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getDiscriminatorMapping(boolean allowSuperclasses)
          Accessor for the discriminator mapping specified .
 org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
          Accessor for Discriminator MetaData
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, int mappingType)
           
 org.datanucleus.metadata.AbstractMemberMetaData getFieldMetaData(java.lang.String fieldName)
          Accessor for the MetaData for the named field
 org.datanucleus.metadata.IdentityType getIdentityType()
          Accessor for the identity type in use.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getIDMapping()
          Accessor for a mapping for the ID.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          Accessor for the mapping for the specified field/property.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(java.lang.String fieldName)
          Accessor for the field mapping for the specified field name.
 org.datanucleus.store.mapped.mapping.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(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping, int mappingType)
           
 java.util.Collection getSecondaryDatastoreClasses()
          Accessor for any secondary tables for this table.
protected  java.util.List getSQLCreateStatements(java.util.Properties props)
          Method to return the necessary SQL create statements for this table.
 org.datanucleus.store.mapped.DatastoreClass getSuperDatastoreClass()
          Accessor for the supertable for this table.
 java.lang.String getType()
          Accessor for the type of the class being represented by this view.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getVersionMapping(boolean allowSuperclasses)
          Accessor for the version mapping specified .
 org.datanucleus.metadata.VersionMetaData getVersionMetaData()
          Accessor for Version MetaData
 void 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(org.datanucleus.store.mapped.DatastoreClass table)
          Accessor whether the supplied DatastoreClass is a supertable of this table.
 boolean managesClass(java.lang.String className)
          Accessor for whether this table manages the specified class
 boolean managesMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
          Convenience method to return if this table manages the columns for the supplied mapping.
 void postInitialize(org.datanucleus.ClassLoaderResolver clr)
          Post initilize.
 void provideDatastoreIdMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
           
 void provideDiscriminatorMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
           
 void provideExternalMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer, int mappingType)
           
 void provideMappingsForMembers(org.datanucleus.store.mapped.mapping.MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] fieldNumbers, boolean includeSecondaryTables)
           
 void provideNonPrimaryKeyMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
           
 void providePrimaryKeyMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
           
 void provideUnmappedDatastoreFields(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Method to provide all unmapped datastore fields (columns) to the consumer.
 void provideVersionMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
           
 
Methods inherited from class org.datanucleus.store.rdbms.table.ViewImpl
addColumnInternal, getSQLDropStatements, preInitialize, validate
 
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addDatastoreField, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getDatastoreField, getDatastoreFields, getDatastoreIdentifierFullyQualified, getIdentifier, getSchemaName, getStoreManager, hasColumnName, hasDatastoreField, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, tableExistsInDatastore, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.datanucleus.store.mapped.DatastoreClass
toString
 
Methods inherited from interface org.datanucleus.store.mapped.DatastoreContainerObject
addDatastoreField, getDatastoreField, getDatastoreFields, getIdentifier, getStoreManager, hasDatastoreField
 

Constructor Detail

ClassView

public ClassView(org.datanucleus.store.mapped.DatastoreIdentifier tableName,
                 RDBMSManager 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 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 interface Table
Parameters:
clr - The ClassLoaderResolver

postInitialize

public void postInitialize(org.datanucleus.ClassLoaderResolver clr)
Post initilize. For things that must be set after all classes have been initialized before

Specified by:
postInitialize in interface Table
Overrides:
postInitialize in class ViewImpl
Parameters:
clr - the ClassLoaderResolver

getIDMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getIDMapping()
Accessor for a mapping for the ID. A view row doesn't have an id as such.

Specified by:
getIDMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Returns:
The ID mapping.

getBaseDatastoreClassWithMember

public org.datanucleus.store.mapped.DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the base datastore class (table) managing the given field. Returns null since we dont manage things the same with views.

Specified by:
getBaseDatastoreClassWithMember in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
mmd - MetaData for the field
Returns:
The base table.

getSuperDatastoreClass

public org.datanucleus.store.mapped.DatastoreClass getSuperDatastoreClass()
Accessor for the supertable for this table.

Specified by:
getSuperDatastoreClass in interface org.datanucleus.store.mapped.DatastoreClass
Returns:
The supertable

isSuperDatastoreClass

public boolean isSuperDatastoreClass(org.datanucleus.store.mapped.DatastoreClass table)
Accessor whether the supplied DatastoreClass is a supertable of this table.

Specified by:
isSuperDatastoreClass in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
table - The DatastoreClass to check
Returns:
Whether it is a supertable (somewhere up the inheritance tree)

getSecondaryDatastoreClasses

public java.util.Collection getSecondaryDatastoreClasses()
Accessor for any secondary tables for this table.

Specified by:
getSecondaryDatastoreClasses in interface org.datanucleus.store.mapped.DatastoreClass
Returns:
Secondary tables (if any)

getDataStoreObjectIdMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getDataStoreObjectIdMapping()
Accessor for the datastore identity id mapping. Returns null since we dont use datastore identity for views.

Specified by:
getDataStoreObjectIdMapping in interface org.datanucleus.store.mapped.DatastoreClass
Returns:
Datastore identity ID mapping

managesClass

public boolean managesClass(java.lang.String className)
Accessor for whether this table manages the specified class

Specified by:
managesClass in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
className - Name of the class
Returns:
Whether it is managed by this table

managesMapping

public boolean managesMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
Convenience method to return if this table manages the columns for the supplied mapping.

Specified by:
managesMapping in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
mapping - The mapping
Returns:
Whether the mapping is managed in this table

getFieldMetaData

public org.datanucleus.metadata.AbstractMemberMetaData getFieldMetaData(java.lang.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 org.datanucleus.store.mapped.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 org.datanucleus.store.mapped.DatastoreClass
Returns:
Whether this is the base datastore class (table)

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 org.datanucleus.store.mapped.DatastoreClass
Returns:
Whether it is attributed in the datastore.

provideDatastoreIdMappings

public void provideDatastoreIdMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Specified by:
provideDatastoreIdMappings in interface org.datanucleus.store.mapped.DatastoreClass

provideDiscriminatorMappings

public void provideDiscriminatorMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Specified by:
provideDiscriminatorMappings in interface org.datanucleus.store.mapped.DatastoreClass

provideMappingsForMembers

public void provideMappingsForMembers(org.datanucleus.store.mapped.mapping.MappingConsumer consumer,
                                      org.datanucleus.metadata.AbstractMemberMetaData[] fieldNumbers,
                                      boolean includeSecondaryTables)
Specified by:
provideMappingsForMembers in interface org.datanucleus.store.mapped.DatastoreClass

provideNonPrimaryKeyMappings

public void provideNonPrimaryKeyMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Specified by:
provideNonPrimaryKeyMappings in interface org.datanucleus.store.mapped.DatastoreClass

providePrimaryKeyMappings

public void providePrimaryKeyMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Specified by:
providePrimaryKeyMappings in interface org.datanucleus.store.mapped.DatastoreClass

provideVersionMappings

public void provideVersionMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Specified by:
provideVersionMappings in interface org.datanucleus.store.mapped.DatastoreClass

provideExternalMappings

public void provideExternalMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer,
                                    int mappingType)
Specified by:
provideExternalMappings in interface org.datanucleus.store.mapped.DatastoreClass

provideUnmappedDatastoreFields

public void provideUnmappedDatastoreFields(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Method to provide all unmapped datastore fields (columns) to the consumer.

Specified by:
provideUnmappedDatastoreFields in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
consumer - Consumer of information

getType

public java.lang.String getType()
Accessor for the type of the class being represented by this view.

Specified by:
getType in interface org.datanucleus.store.mapped.DatastoreClass
Returns:
The name of the class being represented here

getMemberMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the mapping for the specified field/property.

Specified by:
getMemberMapping in interface org.datanucleus.store.mapped.DatastoreClass
Specified by:
getMemberMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Parameters:
mmd - Metadata for the field/property
Returns:
The Mapping for the field.

getMemberMappingInDatastoreClass

public org.datanucleus.store.mapped.mapping.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 org.datanucleus.store.mapped.DatastoreClass
Parameters:
mmd - Metadata of the field/property
Returns:
The Mapping for the field (or null if not present here)

getMemberMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(java.lang.String fieldName)
Accessor for the field mapping for the specified field name.

Specified by:
getMemberMapping in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
fieldName - Name of the field
Returns:
The Java type mapping for the field

getSQLCreateStatements

protected java.util.List getSQLCreateStatements(java.util.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.

getDiscriminatorMetaData

public final org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
Accessor for Discriminator MetaData

Specified by:
getDiscriminatorMetaData in interface org.datanucleus.store.mapped.DatastoreContainerObject
Overrides:
getDiscriminatorMetaData in class AbstractTable
Returns:
Returns the Discriminator MetaData.

getDiscriminatorMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getDiscriminatorMapping(boolean allowSuperclasses)
Accessor for the discriminator mapping specified .

Specified by:
getDiscriminatorMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Overrides:
getDiscriminatorMapping in class AbstractTable
Returns:
The mapping for the discriminator datastore field

getVersionMetaData

public final org.datanucleus.metadata.VersionMetaData getVersionMetaData()
Accessor for Version MetaData

Specified by:
getVersionMetaData in interface org.datanucleus.store.mapped.DatastoreContainerObject
Overrides:
getVersionMetaData in class AbstractTable
Returns:
Returns the Version MetaData.

getVersionMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getVersionMapping(boolean allowSuperclasses)
Accessor for the version mapping specified .

Specified by:
getVersionMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Overrides:
getVersionMapping in class AbstractTable
Returns:
The mapping for the version datastore field

getExternalMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd,
                                                                               int mappingType)
Specified by:
getExternalMapping in interface org.datanucleus.store.mapped.DatastoreClass

getMetaDataForExternalMapping

public org.datanucleus.metadata.AbstractMemberMetaData getMetaDataForExternalMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping,
                                                                                     int mappingType)
Specified by:
getMetaDataForExternalMapping in interface org.datanucleus.store.mapped.DatastoreClass


Copyright © 2009. All Rights Reserved.