Package org.apache.openjpa.jdbc.meta
Class FieldMapping
java.lang.Object
org.apache.openjpa.meta.Extensions
org.apache.openjpa.meta.FieldMetaData
org.apache.openjpa.jdbc.meta.FieldMapping
- All Implemented Interfaces:
Serializable
,FieldStrategy
,Strategy
,ValueMapping
,Commentable
,MetaDataContext
,MetaDataModes
,ValueMetaData
Specialization of metadata for relational databases.
- Author:
- Abe White
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.openjpa.meta.FieldMetaData
FieldMetaData.MemberProvider
-
Field Summary
Fields inherited from class org.apache.openjpa.meta.FieldMetaData
MANAGE_NONE, MANAGE_PERSISTENT, MANAGE_TRANSACTIONAL, MANY_TO_MANY, MANY_TO_ONE, NULL_DEFAULT, NULL_EXCEPTION, NULL_NONE, NULL_UNSET, ONE_TO_MANY, ONE_TO_ONE
Fields inherited from class org.apache.openjpa.meta.Extensions
OPENJPA
Fields inherited from interface org.apache.openjpa.lib.xml.Commentable
EMPTY_COMMENTS
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.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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
appendIndex
(SQLBuffer sql, Select sel, Joins joins) Append the ordered column alias to the given statement.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
appendType
(SQLBuffer sql, Select sel, Joins joins) Append the entity discriminator value to the given statement.void
Clear mapping information, including strategy.void
copy
(FieldMetaData fmd) Copy state from the given field to this one.void
Copy mapping info from the given instance to this one.void
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.getAlias()
Return the alias of this strategy.I/O information on the foreign key, or columns if this value doesn't have a key.Column[]
The columns that hold the data for this value.Convenience method to perform cast fromValueMetaData.getDeclaredTypeMetaData()
.Convenience method to perform cast fromFieldMetaData.getDeclaringMetaData()
Convenience method to perform cast fromFieldMetaData.getDefiningMetaData()
int
The eager fetch mode, as one of the eager constants inJDBCFetchConfiguration
.Convenience method to perform cast fromFieldMetaData.getElement()
Convenience method to perform cast fromValueMetaData.getEmbeddedMetaData()
.Convenience method to perform cast fromValueMetaData.getFieldMetaData()
.If this value joins to another record, the foreign key.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.The handler used for this value, or null if none.Return all independently-mapped joinable types for this value, depending on whether this value is polymorphic and how the related type is mapped.Convenience method to perform cast fromFieldMetaData.getInverseMetaDatas()
I/O information on the join columns.int
The join direction.Foreign key linking the field table to the class' primary table.Index on join foreign key columns.Unique[]
Unique constraint on join foreign key columns.Convenience method to perform cast fromFieldMetaData.getKey()
Convenience method to perform cast fromFieldMetaData.getMappedByMetaData()
Raw mapping data about field's join to parent table, as well as miscellaneous specialized columns like order column.Convenience method to perform cast fromFieldMetaData.getRepository()
Field order column, if any.I/O information for order column.int
The degree to which this relation is polymorphic.getRow
(OpenJPAStateManager sm, JDBCStore store, RowManager rm, int action) Return the row to use for this field.int
Return theorg.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.The strategy used to map this mapping.getTable()
The mapping's primary table.Convenience method to perform cast fromValueMetaData.getTypeMetaData()
.boolean
Whether to use class criteria when joining to related type.Index on this value's columns, or null if none.Raw mapping data.Convenience method to perform cast fromValueMetaData.getValueMappedByMetaData()
.Convenience method to perform cast fromFieldMetaData.getValue()
Unique constraint on this value's columns, or null if none.boolean
void
Perform caching and other initialization operations.void
insert
(OpenJPAStateManager sm, JDBCStore store, RowManager rm) Set values for the mapping into the proper rows.boolean
boolean
Affirms if this field is the non-owning side of a bidirectional relation with a join table.boolean
Affirms if this field is the owning side of a bidirectional relation with a join table.boolean
isCustomDelete
(OpenJPAStateManager sm, JDBCStore store) ReturnBoolean.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.isCustomInsert
(OpenJPAStateManager sm, JDBCStore store) ReturnBoolean.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.isCustomUpdate
(OpenJPAStateManager sm, JDBCStore store) ReturnBoolean.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
boolean
Whether the eager joins or selects used by this field are to-many.boolean
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
boolean
boolean
boolean
boolean
Return true if this field can be used as part of a state image for optimistic locking.Join this value to the class table.Joins from the owning class' table to the table where this field lies using the join foreign key.Return any joins needed to get from the primary table to this table.Join the key value to the class table.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.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.loadEagerParallel
(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res) Load the batched eager result.loadKeyProjection
(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) Load this field's key value using the given result.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) Deprecated.void
mapConstraints
(DBIdentifier name, boolean adapt) Map indexes and constraints for this value, using the currentValueMappingInfo
.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
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
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 inJDBCFetchConfiguration
.void
setFieldMapping
(FieldMapping owner) Set the class mapping using this strategy.void
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
setForeignKey
(Row row, OpenJPAStateManager sm, int targetNumber) 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
I/O information on the join columns.void
setJoinDirection
(int direction) The join direction.void
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
setJoinTableUniques
(Unique[] unqs) void
setJoinUnique
(Unique unq) Unique constraint on join foreign key columns.void
setMappedByIdValue
(Object target, Object val, String mappedByIdFieldName) void
setMapsIdCols
(boolean hasMapsIdCols) void
setOrderColumn
(Column order) Field order column, if any.void
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
UpdateMappingInfo
with our current mapping information.toDataStoreValue
(Object val, JDBCStore store) Translate the given external field value to its datastore equivalent.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
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 awherePrimaryKey
orwhereForeignKey
condition to the given select, depending on whether we have a join foreign key.Methods inherited from class org.apache.openjpa.meta.FieldMetaData
addEmbeddedMetaData, addEmbeddedMetaData, addExtensionKeys, backingMember, compareTo, copy, equals, getAccessType, getAssociationType, getBackingMember, getCascadeAttach, getCascadeDelete, getCascadeDetach, getCascadePersist, getCascadeRefresh, getComments, getConverter, 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, getMappedByField, getMappedByIdValue, getMappedByMetaData, getName, getNullValue, getObjectIdFieldType, getObjectIdFieldTypeCode, getOrderDeclaration, getOrders, getPrimaryKeyIndex, getProxyType, getRealName, getRelationType, getRepository, getResolve, getSetterName, getType, getTypeCode, getTypeMetaData, getTypeOverride, getUpdateStrategy, getUseSchemaElement, getValue, getValueMappedBy, getValueMappedByMetaData, getValueSequenceMetaData, getValueSequenceName, getValueStrategy, hashCode, isDeclaredTypePC, isDefaultFetchGroupExplicit, isElementCollection, isEmbedded, isEmbeddedPC, isExplicit, isExternalized, isInDefaultFetchGroup, isInFetchGroup, isLRS, isMappedById, isPersistentCollection, isPrimaryKey, isSerialized, isStream, isTransient, isTypePC, isUsedInOrderBy, isValueGenerated, isVersion, order, setAccessType, setAssociationType, setCascadeAttach, setCascadeDelete, setCascadeDetach, setCascadePersist, setCascadePersist, setCascadeRefresh, setComments, setConverter, setDeclaredIndex, setDeclaredType, setDeclaredTypeCode, setDeclaringType, setDefaultFetchGroupExplicit, setDelayCapable, setElementCollection, setEmbedded, setExplicit, setExternalizer, setExternalValues, setFactory, setInDefaultFetchGroup, setIndex, setInFetchGroup, setInitializer, setInverse, setListingIndex, setLoadFetchGroup, setLRS, setManagement, setMappedBy, setMappedByIdValue, setNullValue, setOrderDeclaration, setOrders, setPersistentCollection, setPrimaryKey, setPrimaryKeyIndex, setProxyType, setResolve, setResolve, setSerialized, setStream, setTransient, setType, setTypeCode, setTypeOverride, setUpdateStrategy, setUsedInOrderBy, setUseSchemaElement, 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.MetaDataContext
getRepository
Methods inherited from interface org.apache.openjpa.meta.ValueMetaData
addEmbeddedMetaData, addEmbeddedMetaData, copy, getCascadeAttach, getCascadeDelete, getCascadeDetach, getCascadePersist, getCascadeRefresh, getDeclaredType, getDeclaredTypeCode, getDeclaredTypeMetaData, getEmbeddedMetaData, getFieldMetaData, getResolve, getType, getTypeCode, getTypeMetaData, getTypeOverride, getValueMappedBy, getValueMappedByMetaData, isDeclaredTypePC, isEmbedded, isEmbeddedPC, isSerialized, isTypePC, setCascadeAttach, setCascadeDelete, setCascadeDetach, setCascadePersist, setCascadePersist, setCascadeRefresh, setDeclaredType, setDeclaredTypeCode, setEmbedded, setResolve, setResolve, setSerialized, setType, setTypeCode, setTypeOverride, setValueMappedBy
-
Constructor Details
-
FieldMapping
Constructor.
-
-
Method Details
-
getMappingInfo
Raw mapping data about field's join to parent table, as well as miscellaneous specialized columns like order column. -
getStrategy
The strategy used to map this mapping. -
setStrategy
The strategy used to map this mapping. Theadapt
parameter determines whether to adapt when mapping the strategy; use null if the strategy should not be mapped. -
getTable
The mapping's primary table. -
getJoinColumnIO
I/O information on the join columns. -
setJoinColumnIO
I/O information on the join columns. -
getJoinForeignKey
Foreign key linking the field table to the class' primary table. -
setJoinForeignKey
Foreign key linking the field table to the class' primary table. -
getJoinUnique
Unique constraint on join foreign key columns. -
setJoinUnique
Unique constraint on join foreign key columns. -
getJoinTableUniques
-
setJoinTableUniques
-
getJoinIndex
Index on join foreign key columns. -
setJoinIndex
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
Field order column, if any. -
setOrderColumn
Field order column, if any. -
getOrderColumnIO
I/O information for order column. -
setOrderColumnIO
I/O information for order column. -
refSchemaComponents
public void refSchemaComponents()Increment the reference count of used schema components.- Specified by:
refSchemaComponents
in interfaceValueMapping
-
clearMapping
public void clearMapping()Clear mapping information, including strategy.- Specified by:
clearMapping
in interfaceValueMapping
-
syncMappingInfo
public void syncMappingInfo()UpdateMappingInfo
with our current mapping information.- Specified by:
syncMappingInfo
in interfaceValueMapping
-
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 classFieldMetaData
-
getEagerFetchMode
public int getEagerFetchMode()The eager fetch mode, as one of the eager constants inJDBCFetchConfiguration
. -
setEagerFetchMode
public void setEagerFetchMode(int mode) The eager fetch mode, as one of the eager constants inJDBCFetchConfiguration
. -
getMappingRepository
Convenience method to perform cast fromFieldMetaData.getRepository()
- Specified by:
getMappingRepository
in interfaceValueMapping
-
getDefiningMapping
Convenience method to perform cast fromFieldMetaData.getDefiningMetaData()
-
getDeclaringMapping
Convenience method to perform cast fromFieldMetaData.getDeclaringMetaData()
-
getKeyMapping
Convenience method to perform cast fromFieldMetaData.getKey()
-
getElementMapping
Convenience method to perform cast fromFieldMetaData.getElement()
-
getValueMapping
Convenience method to perform cast fromFieldMetaData.getValue()
-
getMappedByMapping
Convenience method to perform cast fromFieldMetaData.getMappedByMetaData()
-
getInverseMappings
Convenience method to perform cast fromFieldMetaData.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 interfaceValueMetaData
- Overrides:
resolve
in classFieldMetaData
-
copyMappingInfo
Copy mapping info from the given instance to this one. -
copy
Description copied from class:FieldMetaData
Copy state from the given field to this one. Do not copy mapping information.- Overrides:
copy
in classFieldMetaData
-
validateDataStoreExtensionPrefix
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 classExtensions
-
getAlias
Description copied from interface:Strategy
Return the alias of this strategy. For custom strategies, return the full class name. -
map
public void map(boolean adapt) Description copied from interface:Strategy
Map the owning mapping using this strategy. -
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 afterStrategy.map(boolean)
, and after all related components have been mapped as well.- Specified by:
initialize
in interfaceStrategy
-
insert
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 interfaceStrategy
- Throws:
SQLException
-
setMappedByIdValue
-
update
Description copied from interface:Strategy
Set values for the mapping into the proper rows.- Specified by:
update
in interfaceStrategy
- Throws:
SQLException
- See Also:
-
delete
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 interfaceStrategy
- Throws:
SQLException
- See Also:
-
deleteRow
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
Description copied from interface:Strategy
ReturnBoolean.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 theStrategy.customInsert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method to implement the custom insertion behavior.- Specified by:
isCustomInsert
in interfaceStrategy
-
isCustomUpdate
Description copied from interface:Strategy
ReturnBoolean.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 theStrategy.customUpdate(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method to override the default update behavior.- Specified by:
isCustomUpdate
in interfaceStrategy
-
isCustomDelete
Description copied from interface:Strategy
ReturnBoolean.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 theStrategy.customDelete(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method to override the default deletion behavior.- Specified by:
isCustomDelete
in interfaceStrategy
-
customInsert
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 interfaceStrategy
- Throws:
SQLException
-
customUpdate
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 interfaceStrategy
- Throws:
SQLException
-
customDelete
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 interfaceStrategy
- Throws:
SQLException
-
setFieldMapping
Description copied from interface:FieldStrategy
Set the class mapping using this strategy. This will be called before use.- Specified by:
setFieldMapping
in interfaceFieldStrategy
-
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 interfaceFieldStrategy
- See Also:
-
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. -
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. -
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 interfaceFieldStrategy
-
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 interfaceFieldStrategy
- Parameters:
sel
- the select to add tosm
- the instance being loaded, or null if not initialized yet or selecting for multiple instancesstore
- the current store managerfetch
- fetch configurationeagerMode
- 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
Return any joins needed to get from the primary table to this table. -
wherePrimaryKey
Add awherePrimaryKey
orwhereForeignKey
condition to the given select, depending on whether we have a join foreign key. -
orderLocal
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 nulljoins
- the joins to this field's table
-
orderRelation
Add ordering to the given select for all relation-based values.- Parameters:
elem
- the related type we're fetchingjoins
- 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 interfaceFieldStrategy
res
- originally theResult
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 interfaceFieldStrategy
- 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 interfaceFieldStrategy
- 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 interfaceFieldStrategy
- Throws:
SQLException
-
toDataStoreValue
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 interfaceFieldStrategy
-
toKeyDataStoreValue
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 interfaceFieldStrategy
-
appendIsEmpty
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 interfaceFieldStrategy
-
appendIsNotEmpty
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 interfaceFieldStrategy
-
appendIsNull
Description copied from interface:FieldStrategy
Append a where clause to the given statement checking if this value is null.- Specified by:
appendIsNull
in interfaceFieldStrategy
-
appendIsNotNull
Description copied from interface:FieldStrategy
Append a where clause to the given statement checking if this value is not null.- Specified by:
appendIsNotNull
in interfaceFieldStrategy
-
appendSize
Description copied from interface:FieldStrategy
Append a where clause to the given statement checking the size of the value.- Specified by:
appendSize
in interfaceFieldStrategy
-
appendIndex
Description copied from interface:FieldStrategy
Append the ordered column alias to the given statement.- Specified by:
appendIndex
in interfaceFieldStrategy
-
appendType
Description copied from interface:FieldStrategy
Append the entity discriminator value to the given statement.- Specified by:
appendType
in interfaceFieldStrategy
-
join
Description copied from interface:FieldStrategy
Join this value to the class table. Does nothing by default.- Specified by:
join
in interfaceFieldStrategy
-
joinKey
Description copied from interface:FieldStrategy
Join the key value to the class table. Does nothing by default.- Specified by:
joinKey
in interfaceFieldStrategy
-
joinRelation
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 interfaceFieldStrategy
traverse
- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
joinKeyRelation
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 interfaceFieldStrategy
traverse
- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
join
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 fromValueMapping.getColumns()
.- Specified by:
loadProjection
in interfaceFieldStrategy
- 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 fromValueMapping.getColumns()
.- Specified by:
loadKeyProjection
in interfaceFieldStrategy
- 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 interfaceFieldStrategy
-
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 interfaceFieldStrategy
- Throws:
SQLException
-
getValueInfo
Description copied from interface:ValueMapping
Raw mapping data.- Specified by:
getValueInfo
in interfaceValueMapping
-
getHandler
Description copied from interface:ValueMapping
The handler used for this value, or null if none.- Specified by:
getHandler
in interfaceValueMapping
-
setHandler
Description copied from interface:ValueMapping
The handler used for this value, or null if none.- Specified by:
setHandler
in interfaceValueMapping
-
getFieldMapping
Description copied from interface:ValueMapping
Convenience method to perform cast fromValueMetaData.getFieldMetaData()
.- Specified by:
getFieldMapping
in interfaceValueMapping
-
getTypeMapping
Description copied from interface:ValueMapping
Convenience method to perform cast fromValueMetaData.getTypeMetaData()
.- Specified by:
getTypeMapping
in interfaceValueMapping
-
getDeclaredTypeMapping
Description copied from interface:ValueMapping
Convenience method to perform cast fromValueMetaData.getDeclaredTypeMetaData()
.- Specified by:
getDeclaredTypeMapping
in interfaceValueMapping
-
getEmbeddedMapping
Description copied from interface:ValueMapping
Convenience method to perform cast fromValueMetaData.getEmbeddedMetaData()
.- Specified by:
getEmbeddedMapping
in interfaceValueMapping
-
getValueMappedByMapping
Description copied from interface:ValueMapping
Convenience method to perform cast fromValueMetaData.getValueMappedByMetaData()
.- Specified by:
getValueMappedByMapping
in interfaceValueMapping
-
getColumns
Description copied from interface:ValueMapping
The columns that hold the data for this value.- Specified by:
getColumns
in interfaceValueMapping
-
setColumns
Description copied from interface:ValueMapping
The columns that hold the data for this value.- Specified by:
setColumns
in interfaceValueMapping
-
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 interfaceValueMapping
-
setColumnIO
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 interfaceValueMapping
-
getForeignKey
Description copied from interface:ValueMapping
If this value joins to another record, the foreign key.- Specified by:
getForeignKey
in interfaceValueMapping
-
getForeignKey
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 interfaceValueMapping
-
setForeignKey
Description copied from interface:ValueMapping
If this value joins to another record, the foreign key.- Specified by:
setForeignKey
in interfaceValueMapping
-
getJoinDirection
public int getJoinDirection()Description copied from interface:ValueMapping
The join direction.- Specified by:
getJoinDirection
in interfaceValueMapping
-
setJoinDirection
public void setJoinDirection(int direction) Description copied from interface:ValueMapping
The join direction.- Specified by:
setJoinDirection
in interfaceValueMapping
-
setForeignKey
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 interfaceValueMapping
- Throws:
SQLException
-
setForeignKey
Description copied from interface:ValueMapping
Sets this value's foreign key to the given related object. The object may be null. If the object is one of2or more foreign keys with the same target, the targetNumber specifies the one to set.- Specified by:
setForeignKey
in interfaceValueMapping
- Throws:
SQLException
-
whereForeignKey
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 interfaceValueMapping
- Throws:
SQLException
-
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 interfaceValueMapping
-
getSelectSubclasses
public int getSelectSubclasses()Description copied from interface:ValueMapping
Return theorg.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 interfaceValueMapping
-
getValueUnique
Description copied from interface:ValueMapping
Unique constraint on this value's columns, or null if none.- Specified by:
getValueUnique
in interfaceValueMapping
-
setValueUnique
Description copied from interface:ValueMapping
Unique constraint on this value's columns, or null if none.- Specified by:
setValueUnique
in interfaceValueMapping
-
getValueIndex
Description copied from interface:ValueMapping
Index on this value's columns, or null if none.- Specified by:
getValueIndex
in interfaceValueMapping
-
setValueIndex
Description copied from interface:ValueMapping
Index on this value's columns, or null if none.- Specified by:
setValueIndex
in interfaceValueMapping
-
getUseClassCriteria
public boolean getUseClassCriteria()Description copied from interface:ValueMapping
Whether to use class criteria when joining to related type.- Specified by:
getUseClassCriteria
in interfaceValueMapping
-
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 interfaceValueMapping
-
getPolymorphic
public int getPolymorphic()Description copied from interface:ValueMapping
The degree to which this relation is polymorphic.- Specified by:
getPolymorphic
in interfaceValueMapping
-
setPolymorphic
public void setPolymorphic(int poly) Description copied from interface:ValueMapping
The degree to which this relation is polymorphic.- Specified by:
setPolymorphic
in interfaceValueMapping
-
mapConstraints
Deprecated.Description copied from interface:ValueMapping
Map indexes and constraints for this value, using the currentValueMappingInfo
. The foreign key or columns of this value must be set before calling this method.- Specified by:
mapConstraints
in interfaceValueMapping
-
mapConstraints
Description copied from interface:ValueMapping
Map indexes and constraints for this value, using the currentValueMappingInfo
. The foreign key or columns of this value must be set before calling this method.- Specified by:
mapConstraints
in interfaceValueMapping
-
copyMappingInfo
Description copied from interface:ValueMapping
Copy mapping info from the given instance to this one.- Specified by:
copyMappingInfo
in interfaceValueMapping
-
isBidirectionalJoinTableMappingOwner
public boolean isBidirectionalJoinTableMappingOwner()Affirms if this field is the owning side of a bidirectional relation with a join table. Evaluated only once and the result cached for subsequent call. Hence must be called after resolution. -
isBidirectionalJoinTableMappingNonOwner
public boolean isBidirectionalJoinTableMappingNonOwner()Affirms if this field is the non-owning side of a bidirectional relation with a join table. Evaluated only once and the result cached for subsequent call. Hence must be called after resolution. -
isBiMTo1JT
public boolean isBiMTo1JT() -
isUni1ToMFK
public boolean isUni1ToMFK() -
isUniMTo1JT
public boolean isUniMTo1JT() -
isUni1To1JT
public boolean isUni1To1JT() -
isBi1To1JT
public boolean isBi1To1JT() -
getBi_1ToM_JTField
-
getBi_MTo1_JTField
-
getBi1ToMJoinFK
-
getBi1ToMElemFK
-
setBi1MJoinTableInfo
public void setBi1MJoinTableInfo() -
isNonDefaultMappingUsingJoinTableStrategy
public boolean isNonDefaultMappingUsingJoinTableStrategy() -
setMapsIdCols
public void setMapsIdCols(boolean hasMapsIdCols) -
hasMapsIdCols
public boolean hasMapsIdCols() -
isDelayCapable
public boolean isDelayCapable()- Overrides:
isDelayCapable
in classFieldMetaData
-