org.jpox.store.rdbms.table
Class ClassView

java.lang.Object
  extended byorg.jpox.store.rdbms.table.AbstractTable
      extended byorg.jpox.store.rdbms.table.ViewImpl
          extended byorg.jpox.store.rdbms.table.ClassView
All Implemented Interfaces:
DatastoreClass, DatastoreContainerObject, DatastoreObject, 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.

Version:
$Revision: 1.26 $

Field Summary
 
Fields inherited from class org.jpox.store.rdbms.table.AbstractTable
columns, columnsByName, dba, ddlDumpWriter, identifier, LOCALISER, state, storeMgr
 
Fields inherited from interface org.jpox.store.rdbms.table.Table
TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED, TABLE_TYPE_MISSING, TABLE_TYPE_TABLE, TABLE_TYPE_UNKNOWN, TABLE_TYPE_VIEW
 
Constructor Summary
ClassView(DatastoreIdentifier tableName, ClassMetaData cmd, RDBMSManager storeMgr, ClassLoaderResolver clr)
          Constructor for class view.
 
Method Summary
 void delete(StateManager sm)
          Method to delete an object from the view.
 void deleteDependent(StateManager sm, AbstractPropertyMetaData[] fieldMetaData)
          Method to delete the dependent objects.
 void fetch(StateManager sm, AbstractPropertyMetaData[] fieldMetaData)
          Method to fetch the fields of an object from the View.
 DatastoreClass getBaseDatastoreClassWithField(AbstractPropertyMetaData fmd)
          Accessor for the base datastore class (table) managing the given field.
 JavaTypeMapping getDataStoreObjectIdMapping()
          Accessor for the datastore identity id mapping.
 JavaTypeMapping getDiscriminatorMapping()
          Accessor for the discriminator mapping specified .
 DiscriminatorMetaData getDiscriminatorMetaData()
          Accessor for Discriminator MetaData
 JavaTypeMapping getExternalFkDiscriminatorMapping(AbstractPropertyMetaData fmd)
          Accessor for the external FK discriminator mapping for an owner field.
 JavaTypeMapping getExternalFkMapping(AbstractPropertyMetaData fmd)
          Accessor for the external FK mapping for an owner field.
 JavaTypeMapping getExternalOrderMapping(AbstractPropertyMetaData fmd)
          Accessor for the external order mapping specified by the field.
 JavaTypeMapping getFieldMapping(AbstractPropertyMetaData fmd)
          Accessor for the mapping for the specified AbstractPropertyMetaData.
 JavaTypeMapping getFieldMapping(java.lang.String fieldName)
          Accessor for the field mapping for the specified field name.
 AbstractPropertyMetaData getFieldMetaData(java.lang.String fieldName)
          Accessor for the MetaData for the named field
 IdentityType getIdentityType()
          Accessor for the identity type in use.
 JavaTypeMapping getIDMapping()
          Accessor for a mapping for the ID.
protected  java.util.List getSQLCreateStatements(java.util.Properties props)
          Method to return the necessary SQL create statements for this table.
 java.lang.String getType()
          Accessor for the type of the class being represented by this view.
 JavaTypeMapping getVersionMapping()
          Accessor for the version mapping specified .
 VersionMetaData getVersionMetaData()
          Accessor for Version MetaData
 void initialize(ClassLoaderResolver clr)
          Method to initialise the view.
 void insert(StateManager sm)
          Method to insert and object into 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.
 void locate(StateManager sm)
          Method to locate an object in the view.
 java.lang.Object newOID(PersistenceManager pm, javax.jdo.spi.PersistenceCapable pc)
          Create a newOID for a class.
 void postInitialize(ClassLoaderResolver clr)
          Post initilize.
 void provideDatastoreIdMappings(MappingConsumer consumer)
          Accessor for a mapping for the datastore ID (OID) for this table.
 void provideDiscriminatorMappings(MappingConsumer consumer)
          Provide the mappings to discriminator mappings
 void provideExternalFkMappings(MappingConsumer consumer)
          Provide the mappings to external FK mappings
 void provideExternalOrderMappings(MappingConsumer consumer)
          Provide the mappings to external order mappings
 void provideMappingsForFields(MappingConsumer consumer, AbstractPropertyMetaData[] fieldNumbers, boolean includeSecondaryTables)
          Provide the mappings to the consumer for all absolute field Numbers in this table that are container in the fieldNumbers parameter.
 void provideNonPrimaryKeyMappings(MappingConsumer consumer)
          Provide the mappings to the consumer for all non primary-key fields mapped to this table.
 void providePrimaryKeyMappings(MappingConsumer consumer)
          Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).
 void provideVersionMappings(MappingConsumer consumer)
          Provide the mappings to version mappings
 void update(StateManager sm, AbstractPropertyMetaData[] fieldMetaData)
          Method to update a view row.
 
Methods inherited from class org.jpox.store.rdbms.table.ViewImpl
addColumnInternal, getSQLDropStatements, preInitialize, validate
 
Methods inherited from class org.jpox.store.rdbms.table.AbstractTable
addDatastoreField, allowDdlDump, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getDatastoreIdentifierFullyQualified, getIdentifier, getSchemaName, getStoreManager, hasColumnName, hasDatastoreField, hashCode, isDumpingDdl, isInitialized, isInitializedModified, isPKInitialized, isValidated, setDdlDumpWriter, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jpox.store.DatastoreClass
toString
 
Methods inherited from interface org.jpox.store.DatastoreContainerObject
addDatastoreField, hasDatastoreField
 
Methods inherited from interface org.jpox.store.DatastoreObject
getIdentifier, getStoreManager
 

Constructor Detail

ClassView

public ClassView(DatastoreIdentifier tableName,
                 ClassMetaData cmd,
                 RDBMSManager storeMgr,
                 ClassLoaderResolver clr)
Constructor for class view.

Parameters:
tableName - The name of the view.
cmd - The metadata for the class represented by this view.
storeMgr - The RDBMS manager managing this view
clr - The ClassLoaderResolver
Method Detail

initialize

public void initialize(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(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 JavaTypeMapping getIDMapping()
Accessor for a mapping for the ID. A view row doesn't have an id as such.

Specified by:
getIDMapping in interface DatastoreContainerObject
Returns:
The ID mapping.

getBaseDatastoreClassWithField

public DatastoreClass getBaseDatastoreClassWithField(AbstractPropertyMetaData fmd)
Accessor for the base datastore class (table) managing the given field. Returns null since we dont manage things the same with views.

Specified by:
getBaseDatastoreClassWithField in interface DatastoreClass
Parameters:
fmd - MetaData for the field
Returns:
The base table.

getDataStoreObjectIdMapping

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

Specified by:
getDataStoreObjectIdMapping in interface DatastoreClass
Returns:
Datastore identity ID mapping

getFieldMetaData

public AbstractPropertyMetaData getFieldMetaData(java.lang.String fieldName)
Accessor for the MetaData for the named field

Specified by:
getFieldMetaData in interface DatastoreClass
Parameters:
fieldName - Name of the field
Returns:
MetaData for the field

getIdentityType

public IdentityType getIdentityType()
Accessor for the identity type in use.

Specified by:
getIdentityType in interface 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 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 DatastoreClass
Returns:
Whether it is attributed in the datastore.

delete

public void delete(StateManager sm)
Method to delete an object from the view. Since it is readonly, we dont support it.

Specified by:
delete in interface DatastoreClass
Parameters:
sm - StateManager of object

deleteDependent

public void deleteDependent(StateManager sm,
                            AbstractPropertyMetaData[] fieldMetaData)
Method to delete the dependent objects. Not supported.

Specified by:
deleteDependent in interface DatastoreClass
Parameters:
sm - StateManager for the object
fieldMetaData - MetaData for the fields

fetch

public void fetch(StateManager sm,
                  AbstractPropertyMetaData[] fieldMetaData)
Method to fetch the fields of an object from the View. Not supported.

Specified by:
fetch in interface DatastoreClass
Parameters:
sm - StateManager of the object
fieldMetaData - MetaData for fields to fetch

insert

public void insert(StateManager sm)
Method to insert and object into the View. Not supported.

Specified by:
insert in interface DatastoreClass
Parameters:
sm - StateManager for object.

locate

public void locate(StateManager sm)
Method to locate an object in the view. We dont support it.

Specified by:
locate in interface DatastoreClass
Parameters:
sm - StateManager for object

update

public void update(StateManager sm,
                   AbstractPropertyMetaData[] fieldMetaData)
Method to update a view row. Since its a view and is readonly we done support it.

Specified by:
update in interface DatastoreClass
Parameters:
sm - StateManager of owner object
fieldMetaData - MetaData of fields to update

provideDatastoreIdMappings

public void provideDatastoreIdMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Accessor for a mapping for the datastore ID (OID) for this table.

Specified by:
provideDatastoreIdMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

provideDiscriminatorMappings

public void provideDiscriminatorMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to discriminator mappings

Specified by:
provideDiscriminatorMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

provideMappingsForFields

public void provideMappingsForFields(MappingConsumer consumer,
                                     AbstractPropertyMetaData[] fieldNumbers,
                                     boolean includeSecondaryTables)
Description copied from interface: DatastoreClass
Provide the mappings to the consumer for all absolute field Numbers in this table that are container in the fieldNumbers parameter.

Specified by:
provideMappingsForFields in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings
fieldNumbers - MetaData of the fields to provide mappings for
includeSecondaryTables - Whether to supply fields in secondary tables

provideNonPrimaryKeyMappings

public void provideNonPrimaryKeyMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to the consumer for all non primary-key fields mapped to this table.

Specified by:
provideNonPrimaryKeyMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

providePrimaryKeyMappings

public void providePrimaryKeyMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).

Specified by:
providePrimaryKeyMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

provideVersionMappings

public void provideVersionMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to version mappings

Specified by:
provideVersionMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the version mappings

provideExternalFkMappings

public void provideExternalFkMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to external FK mappings

Specified by:
provideExternalFkMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

provideExternalOrderMappings

public void provideExternalOrderMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to external order mappings

Specified by:
provideExternalOrderMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

newOID

public final java.lang.Object newOID(PersistenceManager pm,
                                     javax.jdo.spi.PersistenceCapable pc)
Create a newOID for a class. Works for datastore identity, or application identity (inc composite keys)

Specified by:
newOID in interface DatastoreClass
Parameters:
pm - The PersistenceManager
pc - The persistence capable object
Returns:
The new OID

getType

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

Specified by:
getType in interface DatastoreClass
Returns:
The name of the class being represented here

getFieldMapping

public JavaTypeMapping getFieldMapping(AbstractPropertyMetaData fmd)
Accessor for the mapping for the specified AbstractPropertyMetaData.

Specified by:
getFieldMapping in interface DatastoreClass
Parameters:
fmd - the AbstractPropertyMetaData
Returns:
The Mapping for the field.

getFieldMapping

public JavaTypeMapping getFieldMapping(java.lang.String fieldName)
Accessor for the field mapping for the specified field name.

Specified by:
getFieldMapping in interface 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 DiscriminatorMetaData getDiscriminatorMetaData()
Accessor for Discriminator MetaData

Specified by:
getDiscriminatorMetaData in interface DatastoreContainerObject
Overrides:
getDiscriminatorMetaData in class AbstractTable
Returns:
Returns the Discriminator MetaData.

getDiscriminatorMapping

public JavaTypeMapping getDiscriminatorMapping()
Accessor for the discriminator mapping specified .

Specified by:
getDiscriminatorMapping in interface DatastoreContainerObject
Overrides:
getDiscriminatorMapping in class AbstractTable
Returns:
The mapping for the discriminator datastore field

getVersionMetaData

public final VersionMetaData getVersionMetaData()
Accessor for Version MetaData

Specified by:
getVersionMetaData in interface DatastoreContainerObject
Overrides:
getVersionMetaData in class AbstractTable
Returns:
Returns the Version MetaData.

getVersionMapping

public JavaTypeMapping getVersionMapping()
Accessor for the version mapping specified .

Specified by:
getVersionMapping in interface DatastoreContainerObject
Overrides:
getVersionMapping in class AbstractTable
Returns:
The mapping for the version datastore field

getExternalOrderMapping

public JavaTypeMapping getExternalOrderMapping(AbstractPropertyMetaData fmd)
Description copied from interface: DatastoreClass
Accessor for the external order mapping specified by the field.

Specified by:
getExternalOrderMapping in interface DatastoreClass
Parameters:
fmd - The metadata for the List field.
Returns:
The index mapping for the specified field.

getExternalFkDiscriminatorMapping

public JavaTypeMapping getExternalFkDiscriminatorMapping(AbstractPropertyMetaData fmd)
Description copied from interface: DatastoreClass
Accessor for the external FK discriminator mapping for an owner field.

Specified by:
getExternalFkDiscriminatorMapping in interface DatastoreClass
Parameters:
fmd - The metadata for the field.
Returns:
The external mapping for the specified field.

getExternalFkMapping

public JavaTypeMapping getExternalFkMapping(AbstractPropertyMetaData fmd)
Description copied from interface: DatastoreClass
Accessor for the external FK mapping for an owner field.

Specified by:
getExternalFkMapping in interface DatastoreClass
Parameters:
fmd - The metadata for the field.
Returns:
The external mapping for the specified field.


Copyright © -2007 . All Rights Reserved.