org.apache.openjpa.jdbc.meta
Class ClassMapping

java.lang.Object
  extended by org.apache.openjpa.meta.Extensions
      extended by org.apache.openjpa.meta.ClassMetaData
          extended by org.apache.openjpa.jdbc.meta.ClassMapping
All Implemented Interfaces:
Serializable, Comparable<ClassMetaData>, ClassStrategy, Strategy, ValueListener, SourceTracker, Commentable, MetaDataContext, MetaDataModes

public class ClassMapping
extends ClassMetaData
implements ClassStrategy

Specialization of metadata for relational databases.

Author:
Abe White
See Also:
Serialized Form

Field Summary
static ClassMapping[] EMPTY_MAPPINGS
           
 
Fields inherited from class org.apache.openjpa.meta.ClassMetaData
ACCESS_EXPLICIT, ACCESS_FIELD, ACCESS_PROPERTY, ACCESS_UNKNOWN, DEFAULT_STRING, ID_APPLICATION, ID_DATASTORE, ID_UNKNOWN, SYNTHETIC
 
Fields inherited from class org.apache.openjpa.meta.Extensions
OPENJPA
 
Fields inherited from interface org.apache.openjpa.lib.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
 
Fields inherited from interface org.apache.openjpa.lib.xml.Commentable
EMPTY_COMMENTS
 
Constructor Summary
protected ClassMapping(Class type, MappingRepository repos)
          Constructor.
protected ClassMapping(ValueMetaData vmd)
          Embedded constructor.
 
Method Summary
 FieldMapping addDeclaredFieldMapping(String name, Class type)
          Convenience method to perform cast from ClassMetaData.addDeclaredField(java.lang.String, java.lang.Class).
 Joinable assertJoinable(Column col)
          Return the joinable for the given column, or throw an exception if none is available.
protected  void clearDefinedFieldCache()
          Clear defined field data.
 void clearMapping()
          Clear mapping information, including strategy.
protected  void clearSubclassCache()
          Clear cached subclass data.
(package private)  boolean contains(Column[] cols, Column c)
           
 void copy(ClassMetaData cls)
          Copy the metadata from the given instance to this one.
 void customDelete(OpenJPAStateManager sm, JDBCStore store)
          Override this method to customize flushing this mapping.
 void customInsert(OpenJPAStateManager sm, JDBCStore store)
          Override this method to customize flushing this mapping.
 ResultObjectProvider customLoad(JDBCStore store, boolean subclasses, JDBCFetchConfiguration fetch, long startIdx, long endIdx)
          Implement this method to customize obtaining a result containing all instances of this class.
 boolean customLoad(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result result)
          Implement this method to customize loading from a Result into an instance.
 boolean customLoad(OpenJPAStateManager sm, JDBCStore store, PCState state, JDBCFetchConfiguration fetch)
          Implement this method to load the state of a given object, without a previous Result.
 void customUpdate(OpenJPAStateManager sm, JDBCStore store)
          Override this method to customize flushing this mapping.
 void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Set the where values appropriately to delete the proper instance, and set all relations on non-secondary tables as updates.
 String getAlias()
          Return the alias of this strategy.
 ColumnIO getColumnIO()
          I/O information on the key columns / join key.
 FieldMapping getDeclaredFieldMapping(int index)
          Convenience method to perform cast from ClassMetaData.getDeclaredField(int).
 FieldMapping getDeclaredFieldMapping(String name)
          Convenience method to perform cast from ClassMetaData.getDeclaredField(int).
 FieldMapping[] getDeclaredFieldMappings()
          Convenience method to perform cast from ClassMetaData.getDeclaredFields().
 FieldMapping[] getDeclaredUnmanagedFieldMappings()
          Convenience method to perform cast from ClassMetaData.getDeclaredUnmanagedFields().
 FieldMapping[] getDefaultFetchGroupFieldMappings()
          Convenience method to perform cast from ClassMetaData.getDefaultFetchGroupFields().
 FieldMapping[] getDefinedFieldMappings()
          Convenience method to perform cast from ClassMetaData.getDefinedFields().
 FieldMapping[] getDefinedFieldMappingsInListingOrder()
          Convenience method to perform cast from ClassMetaData.getDefinedFieldsInListingOrder().
 Discriminator getDiscriminator()
          The class discriminator.
 ValueMapping getEmbeddingMapping()
          Convenience method to perform cast from ClassMetaData.getEmbeddingMetaData()
 FieldMapping getFieldMapping(int index)
          Convenience method to perform cast from ClassMetaData.getField(int).
 FieldMapping getFieldMapping(String name)
          Convenience method to perform cast from ClassMetaData.getField(int).
 FieldMapping[] getFieldMappings()
          Convenience method to perform cast from ClassMetaData.getFields().
 FieldMapping[] getFieldMappingsInListingOrder()
          Convenience method to perform cast from ClassMetaData.getFieldsInListingOrder().
 ClassMapping[] getIndependentAssignableMappings()
          Returns the closest-derived list of non-inter-joinable mapped types assignable to this type.
 Joinable getJoinable(Column col)
          Return the Joinable for the given column.
 ClassMapping[] getJoinablePCSubclassMappings()
          Return mapped subclasses that are reachable via joins.
 ClassMapping getJoinablePCSuperclassMapping()
          Return the nearest mapped superclass that can join to this class.
 ForeignKey getJoinForeignKey()
          Foreign key linking the primary key columns to the superclass table, or null if none.
 ClassMapping[] getMappedPCSubclassMappings()
          Convenience method to perform cast from ClassMetaData.getMappedPCSubclassMetaDatas().
 ClassMapping getMappedPCSuperclassMapping()
          Convenience method to perform cast from ClassMetaData.getMappedPCSuperclassMetaData().
 ClassMappingInfo getMappingInfo()
          Raw mapping data.
 MappingRepository getMappingRepository()
          Convenience method to perform cast from ClassMetaData.getRepository().
 Object getObjectId(JDBCStore store, Result res, ForeignKey fk, boolean subs, Joins joins)
          Return the oid value stored in the result.
 ClassMapping[] getPCSubclassMappings()
          Convenience method to perform cast from ClassMetaData.getPCSubclassMetaDatas().
 ClassMapping getPCSuperclassMapping()
          Convenience method to perform cast from ClassMetaData.getPCSuperclassMetaData().
 Column[] getPrimaryKeyColumns()
          The columns this mapping uses to uniquely identify an object.
 FieldMapping[] getPrimaryKeyFieldMappings()
          Convenience method to perform cast from ClassMetaData.getPrimaryKeyFields().
 ClassStrategy getStrategy()
          The strategy used to map this mapping.
 int getSubclassFetchMode()
          The subclass fetch mode, as one of the eager constants in JDBCFetchConfiguration.
 Table getTable()
          The mapping's primary table.
 Version getVersion()
          The version indicator.
 FieldMapping getVersionFieldMapping()
          Convenience method to perform cast from ClassMetaData.getVersionField().
 void initialize()
          Perform caching and other initialization operations.
protected  void initializeMapping()
          Initialize mapping.
 void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Set values for the mapping into the proper rows.
 Boolean isCustomDelete(OpenJPAStateManager sm, JDBCStore store)
          Return Boolean.FALSE if this mapping does not customize the delete process, Boolean.TRUE if it does, or null if it does customize the delete, but also relies on the standard delete method being called.
 Boolean isCustomInsert(OpenJPAStateManager sm, JDBCStore store)
          Return Boolean.FALSE if this mapping does not customize the insert process, Boolean.TRUE if it does, or null if it does customize the insert, but also relies on the standard insert method being called.
 Boolean isCustomUpdate(OpenJPAStateManager sm, JDBCStore store)
          Return Boolean.FALSE if this mapping does not customize the update process, Boolean.TRUE if it does, or null if it does customize the update, but also relies on the standard update method being called.
 Boolean isForeignKeyObjectId(ForeignKey fk)
          Return whether the columns of the given foreign key to this mapping can be used to construct an object id for this type.
 boolean isMapped()
          Returns true if this class does not use the "none" strategy (including if it has a null strategy, and therefore is probably in the process of being mapped).
 boolean isPrimaryKeyObjectId(boolean hasAll)
          Return true if the this class' primary key columns correspond to the base class' primary key columns used to construct oid values.
(package private)  boolean isSelfReference(ForeignKey fk, Column[] cols)
           
 boolean isVerticalStrategy()
           
 Joins joinSuperclass(Joins joins, boolean toThis)
          Join the mapping and its superclass.
 void map(boolean adapt)
          Map the owning mapping using this strategy.
 void refSchemaComponents()
           
protected  void resolveMapping(boolean runtime)
          Resolve mapping data.
(package private)  void resolveNonRelationMappings()
          Resolve non-relation field mappings so that when we do relation mappings they can rely on them for joins.
 void setClassMapping(ClassMapping owner)
          Set the class mapping using this strategy.
 void setColumnIO(ColumnIO io)
          I/O information on the key columns / join key.
protected  void setDescribedType(Class type)
          Set the class described by this metadata.
 void setJoinable(Column col, Joinable joinable)
          Add the given column-to-joinable mapping.
 void setJoinForeignKey(ForeignKey fk)
          Foreign key linking the primary key columns to the superclass table, or null if none.
 void setPrimaryKeyColumns(Column[] cols)
          The columns this mapping uses to uniquely identify an object.
 void setStrategy(ClassStrategy strategy, Boolean adapt)
          The strategy used to map this mapping.
 void setSubclassFetchMode(int mode)
          The subclass fetch mode, as one of the eager constants in JDBCFetchConfiguration.
 void setTable(Table table)
          The mapping's primary table.
 boolean supportsEagerSelect(Select sel, OpenJPAStateManager sm, JDBCStore store, ClassMapping base, JDBCFetchConfiguration fetch)
          Return true if this strategy can perform the given select from the given base mapping.
 void syncMappingInfo()
          Update MappingInfo with our current mapping information.
 Object toDataStoreValue(Object obj, Column[] cols, JDBCStore store)
          Return the given column value(s) for the given object.
 void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Set values for the mapping into the proper rows.
protected  boolean validateDataStoreExtensionPrefix(String prefix)
          Return true if extensions starting with the given official datastore prefix should be validated for this runtime.
 
Methods inherited from class org.apache.openjpa.meta.ClassMetaData
addDeclaredFetchGroup, addDeclaredField, addDeclaredInterface, addDefinedSuperclassField, addExtensionKeys, clearAllFieldCache, clearFieldCache, compareTo, defineSuperclassFields, equals, getAccessType, getCacheEnabled, getColNumber, getComments, getCustomFetchGroups, getDataCache, getDataCacheEnabled, getDataCacheName, getDataCacheTimeout, getDeclaredFetchGroups, getDeclaredField, getDeclaredField, getDeclaredFieldNames, getDeclaredFields, getDeclaredInterfaces, getDeclaredUnmanagedFields, getDefaultFetchGroupFields, getDefinedFields, getDefinedFieldsInListingOrder, getDefinedSuperclassField, getDescribedType, getDescribedTypeString, getDetachedState, getDetachedStateField, getEmbeddingMetaData, getEnvClassLoader, getExtraFieldDataIndex, getExtraFieldDataLength, getFetchGroup, getField, getField, getFieldNames, getFields, getFieldsInListingOrder, getIdentitySequenceMetaData, getIdentitySequenceName, getIdentityStrategy, getIdentityType, getInterfaceAliasedProperties, getInterfaceImpl, getInterfacePropertyAlias, getLifecycleMetaData, getLineNumber, getListingIndex, getLrsFields, getMappedPCSubclassMetaDatas, getMappedPCSuperclassMetaData, getObjectIdType, getPCSubclasses, getPCSubclassMetaDatas, getPCSuperclass, getPCSuperclassMetaData, getPrimaryKeyFields, getProxyFields, getRepository, getRequiresExtent, getResolve, getResourceName, getSourceFile, getSourceMode, getSourceName, getSourceScope, getSourceType, getSuperclassField, getTypeAlias, getVersionField, hasAbstractPKField, hashCode, hasPKFieldsFromAbstractClass, isAbstract, isAccessibleField, isDetachable, isEmbeddable, isEmbeddedOnly, isExplicitAccess, isIntercepting, isManagedInterface, isMixedAccess, isObjectIdTypeShared, isOpenJPAIdentity, registerForValueUpdate, removeDeclaredFetchGroup, removeDeclaredField, removeDeclaredInterface, removeDefinedSuperclassField, resolve, resolveMeta, setAbstract, setAccessType, setCacheEnabled, setColNumber, setComments, setDataCacheName, setDataCacheTimeout, setDetachable, setDetachedState, setEmbeddable, setEmbeddedOnly, setEnvClassLoader, setIdentitySequenceName, setIdentityStrategy, setIdentityType, setIntercepting, setInterfaceImpl, setInterfacePropertyAlias, setLineNumber, setListingIndex, setManagedInterface, setObjectIdType, setPCSuperclass, setPCSuperclassMetaData, setRequiresExtent, setResolve, setResolve, setSource, setSourceMode, setSourceMode, setTypeAlias, toString, useIdClassFromParent, usesDetachedState, validateMapping, validateMeta, valueChanged
 
Methods inherited from class org.apache.openjpa.meta.Extensions
addExtension, addExtension, copy, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension, validateExtensionKeys
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_MAPPINGS

public static final ClassMapping[] EMPTY_MAPPINGS
Constructor Detail

ClassMapping

protected ClassMapping(Class type,
                       MappingRepository repos)
Constructor. Supply described type and owning repository.


ClassMapping

protected ClassMapping(ValueMetaData vmd)
Embedded constructor. Supply embedding value and owning repository.

Method Detail

getDiscriminator

public Discriminator getDiscriminator()
The class discriminator.


getVersion

public Version getVersion()
The version indicator.


getObjectId

public Object getObjectId(JDBCStore store,
                          Result res,
                          ForeignKey fk,
                          boolean subs,
                          Joins joins)
                   throws SQLException
Return the oid value stored in the result. This implementation will recurse until it finds an ancestor class who uses oid values for its primary key.

Parameters:
fk - if non-null, use the local columns of the given foreign key in place of this class' primary key columns
Throws:
SQLException
See Also:
isPrimaryKeyObjectId(boolean)

isSelfReference

boolean isSelfReference(ForeignKey fk,
                        Column[] cols)

toDataStoreValue

public Object toDataStoreValue(Object obj,
                               Column[] cols,
                               JDBCStore store)
Return the given column value(s) for the given object. The given columns will be primary key columns of this mapping, but may be in any order. If there is only one column, return its value. If there are multiple columns, return an object array of their values, in the same order the columns are given.


assertJoinable

public Joinable assertJoinable(Column col)
Return the joinable for the given column, or throw an exception if none is available.


getJoinable

public Joinable getJoinable(Column col)
Return the Joinable for the given column. Any column that another mapping joins to must be controlled by a joinable.


setJoinable

public void setJoinable(Column col,
                        Joinable joinable)
Add the given column-to-joinable mapping.


isForeignKeyObjectId

public Boolean isForeignKeyObjectId(ForeignKey fk)
Return whether the columns of the given foreign key to this mapping can be used to construct an object id for this type. This is a relatively expensive operation; its results should be cached.

Returns:
Boolean.TRUE if the foreign key contains all oid columns, null if it contains only some columns, or Boolean.FALSE if it contains non-oid columns

getMappingInfo

public ClassMappingInfo getMappingInfo()
Raw mapping data.


getStrategy

public ClassStrategy getStrategy()
The strategy used to map this mapping.


setStrategy

public void setStrategy(ClassStrategy strategy,
                        Boolean adapt)
The strategy used to map this mapping. The adapt parameter determines whether to adapt when mapping the strategy; use null if the strategy should not be mapped.


getTable

public Table getTable()
The mapping's primary table.


setTable

public void setTable(Table table)
The mapping's primary table.


getPrimaryKeyColumns

public Column[] getPrimaryKeyColumns()
The columns this mapping uses to uniquely identify an object. These will typically be the primary key columns or the columns this class uses to link to its superclass table.


setPrimaryKeyColumns

public void setPrimaryKeyColumns(Column[] cols)
The columns this mapping uses to uniquely identify an object. These will typically be the primary key columns or the columns this class uses to link to its superclass table.


getColumnIO

public ColumnIO getColumnIO()
I/O information on the key columns / join key.


setColumnIO

public void setColumnIO(ColumnIO io)
I/O information on the key columns / join key.


getJoinForeignKey

public ForeignKey getJoinForeignKey()
Foreign key linking the primary key columns to the superclass table, or null if none.


setJoinForeignKey

public void setJoinForeignKey(ForeignKey fk)
Foreign key linking the primary key columns to the superclass table, or null if none.


refSchemaComponents

public void refSchemaComponents()

clearMapping

public void clearMapping()
Clear mapping information, including strategy.


syncMappingInfo

public void syncMappingInfo()
Update MappingInfo with our current mapping information.


setDescribedType

protected void setDescribedType(Class type)
Description copied from class: ClassMetaData
Set the class described by this metadata. The type may be reset when an embedded value changes its declared type.

Overrides:
setDescribedType in class ClassMetaData

getSubclassFetchMode

public int getSubclassFetchMode()
The subclass fetch mode, as one of the eager constants in JDBCFetchConfiguration.


setSubclassFetchMode

public void setSubclassFetchMode(int mode)
The subclass fetch mode, as one of the eager constants in JDBCFetchConfiguration.


getMappingRepository

public MappingRepository getMappingRepository()
Convenience method to perform cast from ClassMetaData.getRepository().


getEmbeddingMapping

public ValueMapping getEmbeddingMapping()
Convenience method to perform cast from ClassMetaData.getEmbeddingMetaData()


isMapped

public boolean isMapped()
Returns true if this class does not use the "none" strategy (including if it has a null strategy, and therefore is probably in the process of being mapped).

Overrides:
isMapped in class ClassMetaData

getPCSuperclassMapping

public ClassMapping getPCSuperclassMapping()
Convenience method to perform cast from ClassMetaData.getPCSuperclassMetaData().


getMappedPCSuperclassMapping

public ClassMapping getMappedPCSuperclassMapping()
Convenience method to perform cast from ClassMetaData.getMappedPCSuperclassMetaData().


getJoinablePCSuperclassMapping

public ClassMapping getJoinablePCSuperclassMapping()
Return the nearest mapped superclass that can join to this class.


getPCSubclassMappings

public ClassMapping[] getPCSubclassMappings()
Convenience method to perform cast from ClassMetaData.getPCSubclassMetaDatas().


getMappedPCSubclassMappings

public ClassMapping[] getMappedPCSubclassMappings()
Convenience method to perform cast from ClassMetaData.getMappedPCSubclassMetaDatas().


getJoinablePCSubclassMappings

public ClassMapping[] getJoinablePCSubclassMappings()
Return mapped subclasses that are reachable via joins.


getIndependentAssignableMappings

public ClassMapping[] getIndependentAssignableMappings()
Returns the closest-derived list of non-inter-joinable mapped types assignable to this type. May return this mapping.


getFieldMappings

public FieldMapping[] getFieldMappings()
Convenience method to perform cast from ClassMetaData.getFields().


getDeclaredFieldMappings

public FieldMapping[] getDeclaredFieldMappings()
Convenience method to perform cast from ClassMetaData.getDeclaredFields().


getPrimaryKeyFieldMappings

public FieldMapping[] getPrimaryKeyFieldMappings()
Convenience method to perform cast from ClassMetaData.getPrimaryKeyFields().


getVersionFieldMapping

public FieldMapping getVersionFieldMapping()
Convenience method to perform cast from ClassMetaData.getVersionField().


getDefaultFetchGroupFieldMappings

public FieldMapping[] getDefaultFetchGroupFieldMappings()
Convenience method to perform cast from ClassMetaData.getDefaultFetchGroupFields().


getDefinedFieldMappings

public FieldMapping[] getDefinedFieldMappings()
Convenience method to perform cast from ClassMetaData.getDefinedFields().


getFieldMappingsInListingOrder

public FieldMapping[] getFieldMappingsInListingOrder()
Convenience method to perform cast from ClassMetaData.getFieldsInListingOrder().


getDefinedFieldMappingsInListingOrder

public FieldMapping[] getDefinedFieldMappingsInListingOrder()
Convenience method to perform cast from ClassMetaData.getDefinedFieldsInListingOrder().


getFieldMapping

public FieldMapping getFieldMapping(int index)
Convenience method to perform cast from ClassMetaData.getField(int).


getDeclaredFieldMapping

public FieldMapping getDeclaredFieldMapping(int index)
Convenience method to perform cast from ClassMetaData.getDeclaredField(int).


getFieldMapping

public FieldMapping getFieldMapping(String name)
Convenience method to perform cast from ClassMetaData.getField(int).


getDeclaredFieldMapping

public FieldMapping getDeclaredFieldMapping(String name)
Convenience method to perform cast from ClassMetaData.getDeclaredField(int).


getDeclaredUnmanagedFieldMappings

public FieldMapping[] getDeclaredUnmanagedFieldMappings()
Convenience method to perform cast from ClassMetaData.getDeclaredUnmanagedFields().


addDeclaredFieldMapping

public FieldMapping addDeclaredFieldMapping(String name,
                                            Class type)
Convenience method to perform cast from ClassMetaData.addDeclaredField(java.lang.String, java.lang.Class).


resolveMapping

protected void resolveMapping(boolean runtime)
Description copied from class: ClassMetaData
Resolve mapping data. Logs resolve message and resolves super by default.

Overrides:
resolveMapping in class ClassMetaData

resolveNonRelationMappings

void resolveNonRelationMappings()
Resolve non-relation field mappings so that when we do relation mappings they can rely on them for joins.


initializeMapping

protected void initializeMapping()
Description copied from class: ClassMetaData
Initialize mapping. Logs init message by default.

Overrides:
initializeMapping in class ClassMetaData

clearDefinedFieldCache

protected void clearDefinedFieldCache()
Description copied from class: ClassMetaData
Clear defined field data.

Overrides:
clearDefinedFieldCache in class ClassMetaData

clearSubclassCache

protected void clearSubclassCache()
Description copied from class: ClassMetaData
Clear cached subclass data.

Overrides:
clearSubclassCache in class ClassMetaData

copy

public void copy(ClassMetaData cls)
Description copied from class: ClassMetaData
Copy the metadata from the given instance to this one. Do not copy mapping information.

Overrides:
copy in class ClassMetaData

validateDataStoreExtensionPrefix

protected boolean validateDataStoreExtensionPrefix(String prefix)
Description copied from class: Extensions
Return true if extensions starting with the given official datastore prefix should be validated for this runtime.

Overrides:
validateDataStoreExtensionPrefix in class Extensions

getAlias

public String getAlias()
Description copied from interface: Strategy
Return the alias of this strategy. For custom strategies, return the full class name.

Specified by:
getAlias in interface Strategy

map

public void map(boolean adapt)
Description copied from interface: Strategy
Map the owning mapping using this strategy.

Specified by:
map in interface Strategy
Parameters:
adapt - if true, use the owning mapping's raw mapping info to set its ORM data; if false, ORM data will already be set

initialize

public void initialize()
Description copied from interface: Strategy
Perform caching and other initialization operations. This method is called after Strategy.map(boolean), and after all related components have been mapped as well.

Specified by:
initialize in interface Strategy

insert

public void insert(OpenJPAStateManager sm,
                   JDBCStore store,
                   RowManager rm)
            throws SQLException
Description copied from interface: Strategy
Set values for the mapping into the proper rows. For class mappings, this method will be called only after the corresponding method has been called for all fields of this mapping.

Specified by:
insert in interface Strategy
Throws:
SQLException

update

public void update(OpenJPAStateManager sm,
                   JDBCStore store,
                   RowManager rm)
            throws SQLException
Description copied from interface: Strategy
Set values for the mapping into the proper rows.

Specified by:
update in interface Strategy
Throws:
SQLException
See Also:
Strategy.insert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.sql.RowManager)

delete

public void delete(OpenJPAStateManager sm,
                   JDBCStore store,
                   RowManager rm)
            throws SQLException
Description copied from interface: Strategy
Set the where values appropriately to delete the proper instance, and set all relations on non-secondary tables as updates. This allows foreign key analysis.

Specified by:
delete in interface Strategy
Throws:
SQLException
See Also:
Strategy.insert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.sql.RowManager)

isCustomInsert

public Boolean isCustomInsert(OpenJPAStateManager sm,
                              JDBCStore store)
Description copied from interface: Strategy
Return Boolean.FALSE if this mapping does not customize the insert process, Boolean.TRUE if it does, or null if it does customize the insert, but also relies on the standard insert method being called. Implement the Strategy.customInsert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore) method to implement the custom insertion behavior.

Specified by:
isCustomInsert in interface Strategy

isCustomUpdate

public Boolean isCustomUpdate(OpenJPAStateManager sm,
                              JDBCStore store)
Description copied from interface: Strategy
Return Boolean.FALSE if this mapping does not customize the update process, Boolean.TRUE if it does, or null if it does customize the update, but also relies on the standard update method being called. Implement the Strategy.customUpdate(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore) method to override the default update behavior.

Specified by:
isCustomUpdate in interface Strategy

isCustomDelete

public Boolean isCustomDelete(OpenJPAStateManager sm,
                              JDBCStore store)
Description copied from interface: Strategy
Return Boolean.FALSE if this mapping does not customize the delete process, Boolean.TRUE if it does, or null if it does customize the delete, but also relies on the standard delete method being called. Implement the Strategy.customDelete(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore) method to override the default deletion behavior.

Specified by:
isCustomDelete in interface Strategy

customInsert

public void customInsert(OpenJPAStateManager sm,
                         JDBCStore store)
                  throws SQLException
Description copied from interface: Strategy
Override this method to customize flushing this mapping. For classes, this method must also flush all fields. For fields, this method is called after the owning object is inserted, so if this field is in a row with other fields, that row will already exist.

Specified by:
customInsert in interface Strategy
Throws:
SQLException

customUpdate

public void customUpdate(OpenJPAStateManager sm,
                         JDBCStore store)
                  throws SQLException
Description copied from interface: Strategy
Override this method to customize flushing this mapping. For classes, this method must also flush all fields.

Specified by:
customUpdate in interface Strategy
Throws:
SQLException

customDelete

public void customDelete(OpenJPAStateManager sm,
                         JDBCStore store)
                  throws SQLException
Description copied from interface: Strategy
Override this method to customize flushing this mapping. For classes, this method must also flush all fields. For fields, this method will be called after the owning object is deleted.

Specified by:
customDelete in interface Strategy
Throws:
SQLException

setClassMapping

public void setClassMapping(ClassMapping owner)
Description copied from interface: ClassStrategy
Set the class mapping using this strategy. This will be called before use.

Specified by:
setClassMapping in interface ClassStrategy

isPrimaryKeyObjectId

public boolean isPrimaryKeyObjectId(boolean hasAll)
Description copied from interface: ClassStrategy
Return true if the this class' primary key columns correspond to the base class' primary key columns used to construct oid values. Base classes always return true. Classes that join to the base class table, though, may not always join using the same columns the base class uses for oid values, or may not use all the columns. When performing a select, we will join down to the most-derived class that is identified by oid values. We cannot use non-primary key field values for joining during selects, because the field values to join on might be the ones we're trying to select! Similarly, we can only reconstruct oid values for selected objects using classes whose primary keys store oid values.

Specified by:
isPrimaryKeyObjectId in interface ClassStrategy
Parameters:
hasAll - if true, there must be a primary key column for every base class primary key column; if false the primary key must only match a subset of the base class primary key columns

joinSuperclass

public Joins joinSuperclass(Joins joins,
                            boolean toThis)
Description copied from interface: ClassStrategy
Join the mapping and its superclass.

Specified by:
joinSuperclass in interface ClassStrategy
toThis - if false, inner join to the superclass table; if true, outer join from the superclass table to this table

supportsEagerSelect

public boolean supportsEagerSelect(Select sel,
                                   OpenJPAStateManager sm,
                                   JDBCStore store,
                                   ClassMapping base,
                                   JDBCFetchConfiguration fetch)
Description copied from interface: ClassStrategy
Return true if this strategy can perform the given select from the given base mapping. The given state manager may be null if selecting multiple instances.

Specified by:
supportsEagerSelect in interface ClassStrategy

customLoad

public ResultObjectProvider customLoad(JDBCStore store,
                                       boolean subclasses,
                                       JDBCFetchConfiguration fetch,
                                       long startIdx,
                                       long endIdx)
                                throws SQLException
Description copied from interface: ClassStrategy
Implement this method to customize obtaining a result containing all instances of this class. Return null for standard loading.

Specified by:
customLoad in interface ClassStrategy
Throws:
SQLException

customLoad

public boolean customLoad(OpenJPAStateManager sm,
                          JDBCStore store,
                          PCState state,
                          JDBCFetchConfiguration fetch)
                   throws SQLException,
                          ClassNotFoundException
Description copied from interface: ClassStrategy
Implement this method to load the state of a given object, without a previous Result. Return true if this method handles the load. If the object does not exist in the data store, simply take no action on it (but still return true). Return false to use default loading.

Specified by:
customLoad in interface ClassStrategy
state - if non-null, then you must initialize the state and persistent object of the given state manager (after determining the actual class of the object from the database, if there are possible persistent subclasses); initialization looks like this: sm.initialize (pcClass, state)
Throws:
SQLException
ClassNotFoundException

customLoad

public boolean customLoad(OpenJPAStateManager sm,
                          JDBCStore store,
                          JDBCFetchConfiguration fetch,
                          Result result)
                   throws SQLException
Description copied from interface: ClassStrategy
Implement this method to customize loading from a Result into an instance. Return true if this mapping handles the load; false if normal loading should proceed after calling this method.

Specified by:
customLoad in interface ClassStrategy
Throws:
SQLException

contains

boolean contains(Column[] cols,
                 Column c)

isVerticalStrategy

public boolean isVerticalStrategy()


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.