Class RelationHandlerMapTableFieldStrategy
java.lang.Object
org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
org.apache.openjpa.jdbc.meta.strats.ContainerFieldStrategy
org.apache.openjpa.jdbc.meta.strats.MapTableFieldStrategy
org.apache.openjpa.jdbc.meta.strats.RelationHandlerMapTableFieldStrategy
- All Implemented Interfaces:
Serializable
,FieldStrategy
,Strategy
,LRSMapFieldStrategy
Mapping for a map whose keys are relations to other persistent objects
and whose values are controlled by a ValueHandler
.
- Since:
- 0.4.0, 1.1.0
- Author:
- Abe White
- See Also:
-
Field Summary
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
field
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionColumn[]
Return the columns holding data for a map key for the given key mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)
orLRSMapFieldStrategy.getIndependentValueMappings(boolean)
(or null).Result[]
getResults
(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, Joins[] resJoins, boolean lrs) Return results containing all keys and values for this map.Column[]
Return the columns holding data for a map value for the given value mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)
orLRSMapFieldStrategy.getIndependentValueMappings(boolean)
(or null).void
Perform caching and other initialization operations.void
insert
(OpenJPAStateManager sm, JDBCStore store, RowManager rm) Set values for the mapping into the proper rows.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.joinKeyRelation
(Joins joins, ClassMapping key) joinRelation
(Joins joins, boolean forceOuter, boolean traverse) Join this value's table to the table for the related first class object type, if any.loadKey
(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) Load a key from the given result.loadValue
(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) Load a value from the given result.void
map
(boolean adapt) Map the owning mapping using this strategy.void
selectKey
(Select sel, ClassMapping key, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) Implement this method to select the keys of this field.void
selectValue
(Select sel, ClassMapping val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) Implement this method to select the values of this field.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.Methods inherited from class org.apache.openjpa.jdbc.meta.strats.MapTableFieldStrategy
delete, deriveKey, deriveValue, getFieldMapping, getIndependentElementMappings, getIndependentKeyMappings, getIndependentValueMappings, getJoinForeignKey, getJoinForeignKey, handleMappedByForeignKey, isTypeUnjoinedSubclass, join, joinKey, joinValueRelation, load, loadKeyProjection, loadProjection, populateKey, supportsSelect
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.ContainerFieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendJoinCount, appendSize, appendUnaliasedJoin
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
appendType, assertNotMappedBy, isEagerSelectToMany, isVersionable, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, where
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, getAlias, isCustomDelete, isCustomInsert, isCustomUpdate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.openjpa.jdbc.meta.FieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendSize, appendType, isEagerSelectToMany, isVersionable, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, where
Methods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, getAlias, isCustomDelete, isCustomInsert, isCustomUpdate
-
Constructor Details
-
RelationHandlerMapTableFieldStrategy
public RelationHandlerMapTableFieldStrategy()
-
-
Method Details
-
getKeyColumns
Description copied from interface:LRSMapFieldStrategy
Return the columns holding data for a map key for the given key mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)
orLRSMapFieldStrategy.getIndependentValueMappings(boolean)
(or null). -
getValueColumns
Description copied from interface:LRSMapFieldStrategy
Return the columns holding data for a map value for the given value mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)
orLRSMapFieldStrategy.getIndependentValueMappings(boolean)
(or null). -
selectKey
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) Description copied from interface:LRSMapFieldStrategy
Implement this method to select the keys of this field. Elements of the result will be loaded withLRSMapFieldStrategy.loadKey(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins)
. This method is only used if the key is not derived from the value. -
selectValue
public void selectValue(Select sel, ClassMapping val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) Description copied from interface:LRSMapFieldStrategy
Implement this method to select the values of this field. Elements of the result will be loaded withLRSMapFieldStrategy.loadValue(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins)
. -
getResults
public Result[] getResults(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, Joins[] resJoins, boolean lrs) throws SQLException Description copied from interface:LRSMapFieldStrategy
Return results containing all keys and values for this map. If only one result is needed, set both array indexes to the same result instance. Also fill in the key and value joins in the given array. The results will be loaded with theLRSMapFieldStrategy.loadKey(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins)
orLRSMapFieldStrategy.deriveKey(org.apache.openjpa.jdbc.kernel.JDBCStore, java.lang.Object)
andLRSMapFieldStrategy.loadValue(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins)
methods.- Throws:
SQLException
-
loadKey
public Object loadKey(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws SQLException Description copied from interface:LRSMapFieldStrategy
Load a key from the given result. This method is only used if the key is not derived from the value.- Throws:
SQLException
-
loadValue
public Object loadValue(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws SQLException Description copied from interface:LRSMapFieldStrategy
Load a value from the given result.- Throws:
SQLException
-
joinKeyRelation
Description copied from class:MapTableFieldStrategy
InvokesFieldStrategy.joinKeyRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)
by default.- Specified by:
joinKeyRelation
in interfaceLRSMapFieldStrategy
- Overrides:
joinKeyRelation
in classMapTableFieldStrategy
-
map
public void map(boolean adapt) Description copied from interface:Strategy
Map the owning mapping using this strategy.- Specified by:
map
in interfaceStrategy
- Overrides:
map
in classMapTableFieldStrategy
- Parameters:
adapt
- if true, use the owning mapping's raw mapping info to set its ORM data; if false, ORM data will already be set
-
initialize
public void initialize()Description copied from interface:Strategy
Perform caching and other initialization operations. This method is called afterStrategy.map(boolean)
, and after all related components have been mapped as well.- Specified by:
initialize
in interfaceStrategy
- Overrides:
initialize
in classAbstractStrategy
-
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
- Overrides:
insert
in classAbstractStrategy
- Throws:
SQLException
-
update
Description copied from interface:Strategy
Set values for the mapping into the proper rows.- Specified by:
update
in interfaceStrategy
- Overrides:
update
in classAbstractStrategy
- Throws:
SQLException
- See Also:
-
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
- Overrides:
joinRelation
in classAbstractFieldStrategy
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
- Overrides:
joinKeyRelation
in classAbstractFieldStrategy
traverse
- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
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
- Overrides:
toDataStoreValue
in classAbstractFieldStrategy
-
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
- Overrides:
toKeyDataStoreValue
in classAbstractFieldStrategy
-