org.apache.openjpa.jdbc.meta
Class FieldMapping

java.lang.Object
  extended by org.apache.openjpa.meta.Extensions
      extended by org.apache.openjpa.meta.FieldMetaData
          extended by org.apache.openjpa.jdbc.meta.FieldMapping
All Implemented Interfaces:
Serializable, FieldStrategy, Strategy, ValueMapping, Commentable, MetaDataContext, MetaDataModes, ValueMetaData

public class FieldMapping
extends FieldMetaData
implements ValueMapping, FieldStrategy

Specialization of metadata for relational databases.

Author:
Abe White
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.openjpa.meta.FieldMetaData
MANAGE_NONE, MANAGE_PERSISTENT, MANAGE_TRANSACTIONAL, NULL_DEFAULT, NULL_EXCEPTION, NULL_NONE, NULL_UNSET
 
Fields inherited from class org.apache.openjpa.meta.Extensions
OPENJPA
 
Fields inherited from interface org.apache.openjpa.jdbc.meta.ValueMapping
JOIN_EXPECTED_INVERSE, JOIN_FORWARD, JOIN_INVERSE, POLY_FALSE, POLY_JOINABLE, POLY_TRUE
 
Fields inherited from interface org.apache.openjpa.meta.ValueMetaData
CASCADE_AUTO, CASCADE_IMMEDIATE, CASCADE_NONE, MAPPED_BY_PK
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
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
FieldMapping(String name, Class type, ClassMapping owner)
          Constructor.
 
Method Summary
 void appendIsEmpty(SQLBuffer sql, Select sel, Joins joins)
          Append a where clause to the given statement checking if this value is empty.
 void appendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins)
          Append a where clause to the given statement checking if this value is not empty.
 void appendIsNotNull(SQLBuffer sql, Select sel, Joins joins)
          Append a where clause to the given statement checking if this value is not null.
 void appendIsNull(SQLBuffer sql, Select sel, Joins joins)
          Append a where clause to the given statement checking if this value is null.
 void appendSize(SQLBuffer sql, Select sel, Joins joins)
          Append a where clause to the given statement checking the size of the value.
 void clearMapping()
          Clear mapping information, including strategy.
 void copy(FieldMetaData fmd)
          Copy state from the given field to this one.
 void copyMappingInfo(FieldMapping fm)
          Copy mapping info from the given instance to this one.
 void copyMappingInfo(ValueMapping vm)
          Copy mapping info 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.
 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.
 void deleteRow(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Delete the row for this object if the reference foreign key exists.
 String getAlias()
          Return the alias of this strategy.
 ColumnIO getColumnIO()
          I/O information on the foreign key, or columns if this value doesn't have a key.
 Column[] getColumns()
          The columns that hold the data for this value.
 ClassMapping getDeclaredTypeMapping()
          Convenience method to perform cast from ValueMetaData.getDeclaredTypeMetaData().
 ClassMapping getDeclaringMapping()
          Convenience method to perform cast from FieldMetaData.getDeclaringMetaData()
 ClassMapping getDefiningMapping()
          Convenience method to perform cast from FieldMetaData.getDefiningMetaData()
 int getEagerFetchMode()
          The eager fetch mode, as one of the eager constants in JDBCFetchConfiguration.
 ValueMapping getElementMapping()
          Convenience method to perform cast from FieldMetaData.getElement()
 ClassMapping getEmbeddedMapping()
          Convenience method to perform cast from ValueMetaData.getEmbeddedMetaData().
 FieldMapping getFieldMapping()
          Convenience method to perform cast from ValueMetaData.getFieldMetaData().
 ForeignKey getForeignKey()
          If this value joins to another record, the foreign key.
 ForeignKey getForeignKey(ClassMapping target)
          Return an equivalent of this value's foreign key, but joining to the given target, which may be an unjoined subclass of this value's related type.
 ValueHandler getHandler()
          The handler used for this value, or null if none.
 ClassMapping[] getIndependentTypeMappings()
          Return all independently-mapped joinable types for this value, depending on whether this value is polymorphic and how the related type is mapped.
 FieldMapping[] getInverseMappings()
          Convenience method to perform cast from FieldMetaData.getInverseMetaDatas()
 ColumnIO getJoinColumnIO()
          I/O information on the join columns.
 int getJoinDirection()
          The join direction.
 ForeignKey getJoinForeignKey()
          Foreign key linking the field table to the class' primary table.
 Index getJoinIndex()
          Index on join foreign key columns.
 Unique getJoinUnique()
          Unique constraint on join foreign key columns.
 ValueMapping getKeyMapping()
          Convenience method to perform cast from FieldMetaData.getKey()
 FieldMapping getMappedByMapping()
          Convenience method to perform cast from FieldMetaData.getMappedByMetaData()
 FieldMappingInfo getMappingInfo()
          Raw mapping data about field's join to parent table, as well as miscellaneous specialized columns like order column.
 MappingRepository getMappingRepository()
          Convenience method to perform cast from FieldMetaData.getRepository()
 Column getOrderColumn()
          Field order column, if any.
 ColumnIO getOrderColumnIO()
          I/O information for order column.
 int getPolymorphic()
          The degree to which this relation is polymorphic.
 Row getRow(OpenJPAStateManager sm, JDBCStore store, RowManager rm, int action)
          Return the row to use for this field.
 int getSelectSubclasses()
          Return the org.apache.openjpa.sql.Select subclasses constant for loading this relation, based on how the related type is mapped, whether this relation is polymorphic, and whether it is configured to use class criteria.
 FieldStrategy getStrategy()
          The strategy used to map this mapping.
 Table getTable()
          The mapping's primary table.
 ClassMapping getTypeMapping()
          Convenience method to perform cast from ValueMetaData.getTypeMetaData().
 boolean getUseClassCriteria()
          Whether to use class criteria when joining to related type.
 Index getValueIndex()
          Index on this value's columns, or null if none.
 ValueMappingInfo getValueInfo()
          Raw mapping data.
 FieldMapping getValueMappedByMapping()
          Convenience method to perform cast from ValueMetaData.getValueMappedByMetaData().
 ValueMapping getValueMapping()
          Convenience method to perform cast from FieldMetaData.getValue()
 Unique getValueUnique()
          Unique constraint on this value's columns, or null if none.
 void initialize()
          Perform caching and other initialization operations.
 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 isEagerSelectToMany()
          Whether the eager joins or selects used by this field are to-many.
 boolean isJoinOuter()
          Whether to use an outer join from the class' primary table.
 boolean isMapped()
          Returns true if field 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 isVersionable()
          Return true if this field can be used as part of a state image for optimistic locking.
 Joins join(Joins joins, boolean forceOuter)
          Join this value to the class table.
 Joins join(Joins joins, boolean forceOuter, boolean toMany)
          Joins from the owning class' table to the table where this field lies using the join foreign key.
 Joins join(Select sel)
          Return any joins needed to get from the primary table to this table.
 Joins joinKey(Joins joins, boolean forceOuter)
          Join the key value to the class table.
 Joins joinKeyRelation(Joins joins, boolean forceOuter, boolean traverse)
          Join this value's table to the table for the related first class object key type, if any.
 Joins joinRelation(Joins joins, boolean forceOuter, boolean traverse)
          Join this value's table to the table for the related first class object type, if any.
 void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
          Load secondary data using a connection from the store manager.
 void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)
          Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.
 void loadEagerJoin(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)
          Load the joined eager result.
 Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res)
          Load the batched eager result.
 Object loadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
          Load this field's key value using the given result.
 Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
          Load this field value using the given result.
 void map(boolean adapt)
          Map the owning mapping using this strategy.
 void mapConstraints(String name, boolean adapt)
          Map indexes and constraints for this value, using the current ValueMappingInfo.
 void mapJoin(boolean adapt, boolean joinRequired)
          Map this field to its table, optionally requiring that it be in another table.
 void mapPrimaryKey(boolean adapt)
          Maps the primary key on the secondary table for this field, if the user's defaults create one.
 void orderLocal(Select sel, ClassMapping elem, Joins joins)
          Add ordering to the given select for all non-relation order values, including the synthetic order column, if any.
 void orderRelation(Select sel, ClassMapping elem, Joins joins)
          Add ordering to the given select for all relation-based values.
 void refSchemaComponents()
          Increment the reference count of used schema components.
 boolean resolve(int mode)
          Resolve and validate metadata.
 int select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
          Select the virtual row columns of this mapping.
 void selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
          Fill in joined select to related objects.
 void selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
          Fill in parallel eager select for related objects.
 void setColumnIO(ColumnIO io)
          I/O information on the foreign key, or columns if this value doesn't have a key.
 void setColumns(Column[] cols)
          The columns that hold the data for this value.
 void setEagerFetchMode(int mode)
          The eager fetch mode, as one of the eager constants in JDBCFetchConfiguration.
 void setFieldMapping(FieldMapping owner)
          Set the class mapping using this strategy.
 void setForeignKey(ForeignKey fk)
          If this value joins to another record, the foreign key.
 void setForeignKey(Row row, OpenJPAStateManager sm)
          Sets this value's foreign key to the given related object.
 void setHandler(ValueHandler handler)
          The handler used for this value, or null if none.
 void setJoinColumnIO(ColumnIO io)
          I/O information on the join columns.
 void setJoinDirection(int direction)
          The join direction.
 void setJoinForeignKey(ForeignKey fk)
          Foreign key linking the field table to the class' primary table.
 void setJoinIndex(Index idx)
          Index on join foreign key columns.
 void setJoinOuter(boolean outer)
          Whether to use an outer join from the class' primary table.
 void setJoinUnique(Unique unq)
          Unique constraint on join foreign key columns.
 void setOrderColumn(Column order)
          Field order column, if any.
 void setOrderColumnIO(ColumnIO io)
          I/O information for order column.
 void setPolymorphic(int poly)
          The degree to which this relation is polymorphic.
 void setStrategy(FieldStrategy strategy, Boolean adapt)
          The strategy used to map this mapping.
 void setUseClassCriteria(boolean criteria)
          Whether to use class criteria when joining to related type.
 void setValueIndex(Index idx)
          Index on this value's columns, or null if none.
 void setValueUnique(Unique unq)
          Unique constraint on this value's columns, or null if none.
 int supportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
          Return whether this mapping can perform the given select type.
 void syncMappingInfo()
          Update MappingInfo with our current mapping information.
 Object toDataStoreValue(Object val, JDBCStore store)
          Translate the given external field value to its datastore equivalent.
 Object toKeyDataStoreValue(Object val, JDBCStore store)
          Translate the given key value to its datastore equivalent.
 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.
 void where(OpenJPAStateManager sm, JDBCStore store, RowManager rm, Object prevValue)
          Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value.
 void whereForeignKey(Row row, OpenJPAStateManager sm)
          Sets this value's foreign key to the given related object.
 void wherePrimaryKey(Select sel, OpenJPAStateManager sm, JDBCStore store)
          Add a wherePrimaryKey or whereForeignKey condition to the given select, depending on whether we have a join foreign key.
 
Methods inherited from class org.apache.openjpa.meta.FieldMetaData
addEmbeddedMetaData, addExtensionKeys, backingMember, compareTo, copy, equals, getBackingMember, getCascadeAttach, getCascadeDelete, getCascadePersist, getCascadeRefresh, getComments, getCustomFetchGroups, getDeclaredIndex, getDeclaredType, getDeclaredTypeCode, getDeclaredTypeMetaData, getDeclaringMetaData, getDeclaringType, getDefiningMetaData, getElement, getEmbeddedMetaData, getExternalizer, getExternalizerMethod, getExternalValue, getExternalValueMap, getExternalValues, getFactory, getFactoryMethod, getFieldMetaData, getFieldValue, getFieldValueMap, getFullName, getFullName, getIndex, getInitializer, getInverse, getInverseMetaDatas, getKey, getListingIndex, getLoadFetchGroup, getManagement, getMappedBy, getMappedByMetaData, getName, getNullValue, getObjectIdFieldType, getObjectIdFieldTypeCode, getOrderDeclaration, getOrders, getPrimaryKeyIndex, getProxyType, getRepository, getResolve, getType, getTypeCode, getTypeMetaData, getTypeOverride, getUpdateStrategy, getValue, getValueMappedBy, getValueMappedByMetaData, getValueSequenceMetaData, getValueSequenceName, getValueStrategy, hashCode, isDeclaredTypePC, isDefaultFetchGroupExplicit, isEmbedded, isEmbeddedPC, isExplicit, isExternalized, isInDefaultFetchGroup, isInFetchGroup, isLRS, isPrimaryKey, isSerialized, isTransient, isTypePC, isValueGenerated, isVersion, order, setCascadeAttach, setCascadeDelete, setCascadePersist, setCascadeRefresh, setComments, setDeclaredIndex, setDeclaredType, setDeclaredTypeCode, setDeclaringType, setDefaultFetchGroupExplicit, setEmbedded, setExplicit, setExternalizer, setExternalValues, setFactory, setInDefaultFetchGroup, setIndex, setInFetchGroup, setInitializer, setInverse, setListingIndex, setLoadFetchGroup, setLRS, setManagement, setMappedBy, setNullValue, setOrderDeclaration, setOrders, setPrimaryKey, setPrimaryKeyIndex, setProxyType, setResolve, setResolve, setSerialized, setTransient, setType, setTypeCode, setTypeOverride, setUpdateStrategy, setUsesImplData, setUsesIntermediate, setValueGenerated, setValueMappedBy, setValueSequenceName, setValueStrategy, setVersion, toString, usesImplData, usesIntermediate
 
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
 
Methods inherited from interface org.apache.openjpa.meta.ValueMetaData
addEmbeddedMetaData, copy, getCascadeAttach, getCascadeDelete, getCascadePersist, getCascadeRefresh, getDeclaredType, getDeclaredTypeCode, getDeclaredTypeMetaData, getEmbeddedMetaData, getFieldMetaData, getResolve, getType, getTypeCode, getTypeMetaData, getTypeOverride, getValueMappedBy, getValueMappedByMetaData, isDeclaredTypePC, isEmbedded, isEmbeddedPC, isSerialized, isTypePC, setCascadeAttach, setCascadeDelete, setCascadePersist, setCascadeRefresh, setDeclaredType, setDeclaredTypeCode, setEmbedded, setResolve, setResolve, setSerialized, setType, setTypeCode, setTypeOverride, setValueMappedBy
 
Methods inherited from interface org.apache.openjpa.meta.MetaDataContext
getRepository
 

Constructor Detail

FieldMapping

public FieldMapping(String name,
                    Class type,
                    ClassMapping owner)
Constructor.

Method Detail

getMappingInfo

public FieldMappingInfo getMappingInfo()
Raw mapping data about field's join to parent table, as well as miscellaneous specialized columns like order column.


getStrategy

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


setStrategy

public void setStrategy(FieldStrategy 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.


getJoinColumnIO

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


setJoinColumnIO

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


getJoinForeignKey

public ForeignKey getJoinForeignKey()
Foreign key linking the field table to the class' primary table.


setJoinForeignKey

public void setJoinForeignKey(ForeignKey fk)
Foreign key linking the field table to the class' primary table.


getJoinUnique

public Unique getJoinUnique()
Unique constraint on join foreign key columns.


setJoinUnique

public void setJoinUnique(Unique unq)
Unique constraint on join foreign key columns.


getJoinIndex

public Index getJoinIndex()
Index on join foreign key columns.


setJoinIndex

public void setJoinIndex(Index idx)
Index on join foreign key columns.


isJoinOuter

public boolean isJoinOuter()
Whether to use an outer join from the class' primary table.


setJoinOuter

public void setJoinOuter(boolean outer)
Whether to use an outer join from the class' primary table.


getOrderColumn

public Column getOrderColumn()
Field order column, if any.


setOrderColumn

public void setOrderColumn(Column order)
Field order column, if any.


getOrderColumnIO

public ColumnIO getOrderColumnIO()
I/O information for order column.


setOrderColumnIO

public void setOrderColumnIO(ColumnIO io)
I/O information for order column.


refSchemaComponents

public void refSchemaComponents()
Increment the reference count of used schema components.

Specified by:
refSchemaComponents in interface ValueMapping

clearMapping

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

Specified by:
clearMapping in interface ValueMapping

syncMappingInfo

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

Specified by:
syncMappingInfo in interface ValueMapping

isMapped

public boolean isMapped()
Returns true if field 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 FieldMetaData

getEagerFetchMode

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


setEagerFetchMode

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


getMappingRepository

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

Specified by:
getMappingRepository in interface ValueMapping

getDefiningMapping

public ClassMapping getDefiningMapping()
Convenience method to perform cast from FieldMetaData.getDefiningMetaData()


getDeclaringMapping

public ClassMapping getDeclaringMapping()
Convenience method to perform cast from FieldMetaData.getDeclaringMetaData()


getKeyMapping

public ValueMapping getKeyMapping()
Convenience method to perform cast from FieldMetaData.getKey()


getElementMapping

public ValueMapping getElementMapping()
Convenience method to perform cast from FieldMetaData.getElement()


getValueMapping

public ValueMapping getValueMapping()
Convenience method to perform cast from FieldMetaData.getValue()


getMappedByMapping

public FieldMapping getMappedByMapping()
Convenience method to perform cast from FieldMetaData.getMappedByMetaData()


getInverseMappings

public FieldMapping[] getInverseMappings()
Convenience method to perform cast from FieldMetaData.getInverseMetaDatas()


resolve

public boolean resolve(int mode)
Description copied from class: FieldMetaData
Resolve and validate metadata. Return true if already resolved.

Specified by:
resolve in interface ValueMetaData
Overrides:
resolve in class FieldMetaData

copyMappingInfo

public void copyMappingInfo(FieldMapping fm)
Copy mapping info from the given instance to this one.


copy

public void copy(FieldMetaData fmd)
Description copied from class: FieldMetaData
Copy state from the given field to this one. Do not copy mapping information.

Overrides:
copy in class FieldMetaData

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

mapJoin

public void mapJoin(boolean adapt,
                    boolean joinRequired)
Map this field to its table, optionally requiring that it be in another table. Utility method for use by mapping strategies.


mapPrimaryKey

public void mapPrimaryKey(boolean adapt)
Maps the primary key on the secondary table for this field, if the user's defaults create one. This must be called after this field is mapped so that it's table has its columns 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)

deleteRow

public void deleteRow(OpenJPAStateManager sm,
                      JDBCStore store,
                      RowManager rm)
               throws SQLException
Delete the row for this object if the reference foreign key exists. Utility method for use by mapping strategies.

Throws:
SQLException

getRow

public Row getRow(OpenJPAStateManager sm,
                  JDBCStore store,
                  RowManager rm,
                  int action)
           throws SQLException
Return the row to use for this field. This method is meant only for single-value fields that might reside in a table that is joined to the primary table through the join foreign key. It is not meant for multi-valued fields like collections and maps. The method checks whether we're using an outer join and if so it deletes the field's previous value, then if the field is non-null returns an insert row for the new value. The join foreign key will already be set on the returned row; mapping strategies just need to set their own values. Utility method for use by mapping strategies.

Throws:
SQLException

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

setFieldMapping

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

Specified by:
setFieldMapping in interface FieldStrategy

supportsSelect

public int supportsSelect(Select sel,
                          int type,
                          OpenJPAStateManager sm,
                          JDBCStore store,
                          JDBCFetchConfiguration fetch)
Description copied from interface: FieldStrategy
Return whether this mapping can perform the given select type. Return 0 if the given type is not supported. If the given type is an eager parallel type, return the number of UNIONed selects necessary to fetch the data. Otherwise, return any positive number if the type is supported. The given state manager may be null if selecting multiple instances.

Specified by:
supportsSelect in interface FieldStrategy
See Also:
Select

selectEagerParallel

public void selectEagerParallel(SelectExecutor sel,
                                OpenJPAStateManager sm,
                                JDBCStore store,
                                JDBCFetchConfiguration fetch,
                                int eagerMode)
Description copied from interface: FieldStrategy
Fill in parallel eager select for related objects.

Specified by:
selectEagerParallel in interface FieldStrategy
See Also:
FieldStrategy.select(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int)

selectEagerJoin

public void selectEagerJoin(Select sel,
                            OpenJPAStateManager sm,
                            JDBCStore store,
                            JDBCFetchConfiguration fetch,
                            int eagerMode)
Description copied from interface: FieldStrategy
Fill in joined select to related objects.

Specified by:
selectEagerJoin in interface FieldStrategy
See Also:
FieldStrategy.select(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int)

isEagerSelectToMany

public boolean isEagerSelectToMany()
Description copied from interface: FieldStrategy
Whether the eager joins or selects used by this field are to-many.

Specified by:
isEagerSelectToMany in interface FieldStrategy

select

public int select(Select sel,
                  OpenJPAStateManager sm,
                  JDBCStore store,
                  JDBCFetchConfiguration fetch,
                  int eagerMode)
Description copied from interface: FieldStrategy
Select the virtual row columns of this mapping.

Specified by:
select in interface FieldStrategy
Parameters:
sel - the select to add to
sm - the instance being loaded, or null if not initialized yet or selecting for multiple instances
store - the current store manager
fetch - fetch configuration
eagerMode - the eager fetch mode to use; this may be more restrictive than the mode of the fetch configuration
Returns:
> 0 if this mapping requires the selected data (if any), 0 if it selected data but does not require it, or < 0 if no data was selected

join

public Joins join(Select sel)
Return any joins needed to get from the primary table to this table.


wherePrimaryKey

public void wherePrimaryKey(Select sel,
                            OpenJPAStateManager sm,
                            JDBCStore store)
Add a wherePrimaryKey or whereForeignKey condition to the given select, depending on whether we have a join foreign key.


orderLocal

public void orderLocal(Select sel,
                       ClassMapping elem,
                       Joins joins)
Add ordering to the given select for all non-relation order values, including the synthetic order column, if any.

Parameters:
elem - the related type we're fetching, or null
joins - the joins to this field's table

orderRelation

public void orderRelation(Select sel,
                          ClassMapping elem,
                          Joins joins)
Add ordering to the given select for all relation-based values.

Parameters:
elem - the related type we're fetching
joins - the joins across the relation

loadEagerParallel

public Object loadEagerParallel(OpenJPAStateManager sm,
                                JDBCStore store,
                                JDBCFetchConfiguration fetch,
                                Object res)
                         throws SQLException
Description copied from interface: FieldStrategy
Load the batched eager result.

Specified by:
loadEagerParallel in interface FieldStrategy
res - originally the Result to load from, but this method may return a processed result form that will be passed to subsequent calls
Throws:
SQLException

loadEagerJoin

public void loadEagerJoin(OpenJPAStateManager sm,
                          JDBCStore store,
                          JDBCFetchConfiguration fetch,
                          Result res)
                   throws SQLException
Description copied from interface: FieldStrategy
Load the joined eager result.

Specified by:
loadEagerJoin in interface FieldStrategy
Throws:
SQLException

load

public void load(OpenJPAStateManager sm,
                 JDBCStore store,
                 JDBCFetchConfiguration fetch,
                 Result res)
          throws SQLException
Description copied from interface: FieldStrategy
Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.

Specified by:
load in interface FieldStrategy
Throws:
SQLException

load

public void load(OpenJPAStateManager sm,
                 JDBCStore store,
                 JDBCFetchConfiguration fetch)
          throws SQLException
Description copied from interface: FieldStrategy
Load secondary data using a connection from the store manager.

Specified by:
load in interface FieldStrategy
Throws:
SQLException

toDataStoreValue

public Object toDataStoreValue(Object val,
                               JDBCStore store)
Description copied from interface: FieldStrategy
Translate the given external field value to its datastore equivalent. If the mapping occupies multiple columns in the datastore, return an object array, else return a single object. Simply returns the given object by default.

Specified by:
toDataStoreValue in interface FieldStrategy

toKeyDataStoreValue

public Object toKeyDataStoreValue(Object val,
                                  JDBCStore store)
Description copied from interface: FieldStrategy
Translate the given key value to its datastore equivalent. If the mapping occupies multiple columns in the datastore, return an object array, else return a single object. Simply returns the given object by default.

Specified by:
toKeyDataStoreValue in interface FieldStrategy

appendIsEmpty

public void appendIsEmpty(SQLBuffer sql,
                          Select sel,
                          Joins joins)
Description copied from interface: FieldStrategy
Append a where clause to the given statement checking if this value is empty. Appends impossible-to-satisfy SQL by default.

Specified by:
appendIsEmpty in interface FieldStrategy

appendIsNotEmpty

public void appendIsNotEmpty(SQLBuffer sql,
                             Select sel,
                             Joins joins)
Description copied from interface: FieldStrategy
Append a where clause to the given statement checking if this value is not empty. Appends always-satisfied SQL by default.

Specified by:
appendIsNotEmpty in interface FieldStrategy

appendIsNull

public void appendIsNull(SQLBuffer sql,
                         Select sel,
                         Joins joins)
Description copied from interface: FieldStrategy
Append a where clause to the given statement checking if this value is null.

Specified by:
appendIsNull in interface FieldStrategy

appendIsNotNull

public void appendIsNotNull(SQLBuffer sql,
                            Select sel,
                            Joins joins)
Description copied from interface: FieldStrategy
Append a where clause to the given statement checking if this value is not null.

Specified by:
appendIsNotNull in interface FieldStrategy

appendSize

public void appendSize(SQLBuffer sql,
                       Select sel,
                       Joins joins)
Description copied from interface: FieldStrategy
Append a where clause to the given statement checking the size of the value.

Specified by:
appendSize in interface FieldStrategy

join

public Joins join(Joins joins,
                  boolean forceOuter)
Description copied from interface: FieldStrategy
Join this value to the class table. Does nothing by default.

Specified by:
join in interface FieldStrategy

joinKey

public Joins joinKey(Joins joins,
                     boolean forceOuter)
Description copied from interface: FieldStrategy
Join the key value to the class table. Does nothing by default.

Specified by:
joinKey in interface FieldStrategy

joinRelation

public Joins joinRelation(Joins joins,
                          boolean forceOuter,
                          boolean traverse)
Description copied from interface: FieldStrategy
Join this value's table to the table for the related first class object type, if any. Does nothing by default.

Specified by:
joinRelation in interface FieldStrategy
traverse - if true, throw proper exception if it is not possible for this mapping to traverse into the related type

joinKeyRelation

public Joins joinKeyRelation(Joins joins,
                             boolean forceOuter,
                             boolean traverse)
Description copied from interface: FieldStrategy
Join this value's table to the table for the related first class object key type, if any. Does nothing by default.

Specified by:
joinKeyRelation in interface FieldStrategy
traverse - if true, throw proper exception if it is not possible for this mapping to traverse into the related type

join

public Joins join(Joins joins,
                  boolean forceOuter,
                  boolean toMany)
Joins from the owning class' table to the table where this field lies using the join foreign key. Utility method for use by mapping strategies.


loadProjection

public Object loadProjection(JDBCStore store,
                             JDBCFetchConfiguration fetch,
                             Result res,
                             Joins joins)
                      throws SQLException
Description copied from interface: FieldStrategy
Load this field value using the given result. The result will contain the columns from ValueMapping.getColumns().

Specified by:
loadProjection in interface FieldStrategy
Throws:
SQLException

loadKeyProjection

public Object loadKeyProjection(JDBCStore store,
                                JDBCFetchConfiguration fetch,
                                Result res,
                                Joins joins)
                         throws SQLException
Description copied from interface: FieldStrategy
Load this field's key value using the given result. The result will contain the columns from ValueMapping.getColumns().

Specified by:
loadKeyProjection in interface FieldStrategy
Throws:
SQLException

isVersionable

public boolean isVersionable()
Description copied from interface: FieldStrategy
Return true if this field can be used as part of a state image for optimistic locking.

Specified by:
isVersionable in interface FieldStrategy

where

public void where(OpenJPAStateManager sm,
                  JDBCStore store,
                  RowManager rm,
                  Object prevValue)
           throws SQLException
Description copied from interface: FieldStrategy
Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value. Only versionable mappings must implement this method meaningfully.

Specified by:
where in interface FieldStrategy
Throws:
SQLException

getValueInfo

public ValueMappingInfo getValueInfo()
Description copied from interface: ValueMapping
Raw mapping data.

Specified by:
getValueInfo in interface ValueMapping

getHandler

public ValueHandler getHandler()
Description copied from interface: ValueMapping
The handler used for this value, or null if none.

Specified by:
getHandler in interface ValueMapping

setHandler

public void setHandler(ValueHandler handler)
Description copied from interface: ValueMapping
The handler used for this value, or null if none.

Specified by:
setHandler in interface ValueMapping

getFieldMapping

public FieldMapping getFieldMapping()
Description copied from interface: ValueMapping
Convenience method to perform cast from ValueMetaData.getFieldMetaData().

Specified by:
getFieldMapping in interface ValueMapping

getTypeMapping

public ClassMapping getTypeMapping()
Description copied from interface: ValueMapping
Convenience method to perform cast from ValueMetaData.getTypeMetaData().

Specified by:
getTypeMapping in interface ValueMapping

getDeclaredTypeMapping

public ClassMapping getDeclaredTypeMapping()
Description copied from interface: ValueMapping
Convenience method to perform cast from ValueMetaData.getDeclaredTypeMetaData().

Specified by:
getDeclaredTypeMapping in interface ValueMapping

getEmbeddedMapping

public ClassMapping getEmbeddedMapping()
Description copied from interface: ValueMapping
Convenience method to perform cast from ValueMetaData.getEmbeddedMetaData().

Specified by:
getEmbeddedMapping in interface ValueMapping

getValueMappedByMapping

public FieldMapping getValueMappedByMapping()
Description copied from interface: ValueMapping
Convenience method to perform cast from ValueMetaData.getValueMappedByMetaData().

Specified by:
getValueMappedByMapping in interface ValueMapping

getColumns

public Column[] getColumns()
Description copied from interface: ValueMapping
The columns that hold the data for this value.

Specified by:
getColumns in interface ValueMapping

setColumns

public void setColumns(Column[] cols)
Description copied from interface: ValueMapping
The columns that hold the data for this value.

Specified by:
setColumns in interface ValueMapping

getColumnIO

public ColumnIO getColumnIO()
Description copied from interface: ValueMapping
I/O information on the foreign key, or columns if this value doesn't have a key.

Specified by:
getColumnIO in interface ValueMapping

setColumnIO

public void setColumnIO(ColumnIO io)
Description copied from interface: ValueMapping
I/O information on the foreign key, or columns if this value doesn't have a key.

Specified by:
setColumnIO in interface ValueMapping

getForeignKey

public ForeignKey getForeignKey()
Description copied from interface: ValueMapping
If this value joins to another record, the foreign key.

Specified by:
getForeignKey in interface ValueMapping

getForeignKey

public ForeignKey getForeignKey(ClassMapping target)
Description copied from interface: ValueMapping
Return an equivalent of this value's foreign key, but joining to the given target, which may be an unjoined subclass of this value's related type.

Specified by:
getForeignKey in interface ValueMapping

setForeignKey

public void setForeignKey(ForeignKey fk)
Description copied from interface: ValueMapping
If this value joins to another record, the foreign key.

Specified by:
setForeignKey in interface ValueMapping

getJoinDirection

public int getJoinDirection()
Description copied from interface: ValueMapping
The join direction.

Specified by:
getJoinDirection in interface ValueMapping

setJoinDirection

public void setJoinDirection(int direction)
Description copied from interface: ValueMapping
The join direction.

Specified by:
setJoinDirection in interface ValueMapping

setForeignKey

public void setForeignKey(Row row,
                          OpenJPAStateManager sm)
                   throws SQLException
Description copied from interface: ValueMapping
Sets this value's foreign key to the given related object. The object may be null.

Specified by:
setForeignKey in interface ValueMapping
Throws:
SQLException

whereForeignKey

public void whereForeignKey(Row row,
                            OpenJPAStateManager sm)
                     throws SQLException
Description copied from interface: ValueMapping
Sets this value's foreign key to the given related object. The object may be null.

Specified by:
whereForeignKey in interface ValueMapping
Throws:
SQLException

getIndependentTypeMappings

public ClassMapping[] getIndependentTypeMappings()
Description copied from interface: ValueMapping
Return all independently-mapped joinable types for this value, depending on whether this value is polymorphic and how the related type is mapped. Return an empty array if value type is not PC.

Specified by:
getIndependentTypeMappings in interface ValueMapping

getSelectSubclasses

public int getSelectSubclasses()
Description copied from interface: ValueMapping
Return the org.apache.openjpa.sql.Select subclasses constant for loading this relation, based on how the related type is mapped, whether this relation is polymorphic, and whether it is configured to use class criteria.

Specified by:
getSelectSubclasses in interface ValueMapping

getValueUnique

public Unique getValueUnique()
Description copied from interface: ValueMapping
Unique constraint on this value's columns, or null if none.

Specified by:
getValueUnique in interface ValueMapping

setValueUnique

public void setValueUnique(Unique unq)
Description copied from interface: ValueMapping
Unique constraint on this value's columns, or null if none.

Specified by:
setValueUnique in interface ValueMapping

getValueIndex

public Index getValueIndex()
Description copied from interface: ValueMapping
Index on this value's columns, or null if none.

Specified by:
getValueIndex in interface ValueMapping

setValueIndex

public void setValueIndex(Index idx)
Description copied from interface: ValueMapping
Index on this value's columns, or null if none.

Specified by:
setValueIndex in interface ValueMapping

getUseClassCriteria

public boolean getUseClassCriteria()
Description copied from interface: ValueMapping
Whether to use class criteria when joining to related type.

Specified by:
getUseClassCriteria in interface ValueMapping

setUseClassCriteria

public void setUseClassCriteria(boolean criteria)
Description copied from interface: ValueMapping
Whether to use class criteria when joining to related type.

Specified by:
setUseClassCriteria in interface ValueMapping

getPolymorphic

public int getPolymorphic()
Description copied from interface: ValueMapping
The degree to which this relation is polymorphic.

Specified by:
getPolymorphic in interface ValueMapping

setPolymorphic

public void setPolymorphic(int poly)
Description copied from interface: ValueMapping
The degree to which this relation is polymorphic.

Specified by:
setPolymorphic in interface ValueMapping

mapConstraints

public void mapConstraints(String name,
                           boolean adapt)
Description copied from interface: ValueMapping
Map indexes and constraints for this value, using the current ValueMappingInfo. The foreign key or columns of this value must be set before calling this method.

Specified by:
mapConstraints in interface ValueMapping

copyMappingInfo

public void copyMappingInfo(ValueMapping vm)
Description copied from interface: ValueMapping
Copy mapping info from the given instance to this one.

Specified by:
copyMappingInfo in interface ValueMapping


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