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
public class RelationHandlerMapTableFieldStrategy extends MapTableFieldStrategy
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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
field
-
-
Constructor Summary
Constructors Constructor Description RelationHandlerMapTableFieldStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Column[]getKeyColumns(ClassMapping cls)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[]getValueColumns(ClassMapping cls)Return the columns holding data for a map value for the given value mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)orLRSMapFieldStrategy.getIndependentValueMappings(boolean)(or null).voidinitialize()Perform caching and other initialization operations.voidinsert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)Set values for the mapping into the proper rows.JoinsjoinKeyRelation(Joins joins, boolean forceOuter, boolean traverse)Join this value's table to the table for the related first class object key type, if any.JoinsjoinKeyRelation(Joins joins, ClassMapping key)JoinsjoinRelation(Joins joins, boolean forceOuter, boolean traverse)Join this value's table to the table for the related first class object type, if any.ObjectloadKey(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)Load a key from the given result.ObjectloadValue(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)Load a value from the given result.voidmap(boolean adapt)Map the owning mapping using this strategy.voidselectKey(Select sel, ClassMapping key, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins)Implement this method to select the keys of this field.voidselectValue(Select sel, ClassMapping val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins)Implement this method to select the values of this field.ObjecttoDataStoreValue(Object val, JDBCStore store)Translate the given external field value to its datastore equivalent.ObjecttoKeyDataStoreValue(Object val, JDBCStore store)Translate the given key value to its datastore equivalent.voidupdate(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
-
-
-
-
Method Detail
-
getKeyColumns
public Column[] getKeyColumns(ClassMapping cls)
Description copied from interface:LRSMapFieldStrategyReturn the columns holding data for a map key for the given key mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)orLRSMapFieldStrategy.getIndependentValueMappings(boolean)(or null).
-
getValueColumns
public Column[] getValueColumns(ClassMapping cls)
Description copied from interface:LRSMapFieldStrategyReturn 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:LRSMapFieldStrategyImplement 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:LRSMapFieldStrategyImplement 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:LRSMapFieldStrategyReturn 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:LRSMapFieldStrategyLoad 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:LRSMapFieldStrategyLoad a value from the given result.- Throws:
SQLException
-
joinKeyRelation
public Joins joinKeyRelation(Joins joins, ClassMapping key)
Description copied from class:MapTableFieldStrategyInvokesFieldStrategy.joinKeyRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)by default.- Specified by:
joinKeyRelationin interfaceLRSMapFieldStrategy- Overrides:
joinKeyRelationin classMapTableFieldStrategy
-
map
public void map(boolean adapt)
Description copied from interface:StrategyMap the owning mapping using this strategy.- Specified by:
mapin interfaceStrategy- Overrides:
mapin 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:StrategyPerform caching and other initialization operations. This method is called afterStrategy.map(boolean), and after all related components have been mapped as well.- Specified by:
initializein interfaceStrategy- Overrides:
initializein classAbstractStrategy
-
insert
public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws SQLException
Description copied from interface:StrategySet 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:
insertin interfaceStrategy- Overrides:
insertin classAbstractStrategy- Throws:
SQLException
-
update
public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws SQLException
Description copied from interface:StrategySet values for the mapping into the proper rows.- Specified by:
updatein interfaceStrategy- Overrides:
updatein classAbstractStrategy- Throws:
SQLException- See Also:
Strategy.insert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.sql.RowManager)
-
joinRelation
public Joins joinRelation(Joins joins, boolean forceOuter, boolean traverse)
Description copied from interface:FieldStrategyJoin this value's table to the table for the related first class object type, if any. Does nothing by default.- Specified by:
joinRelationin interfaceFieldStrategy- Overrides:
joinRelationin classAbstractFieldStrategytraverse- 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:FieldStrategyJoin this value's table to the table for the related first class object key type, if any. Does nothing by default.- Specified by:
joinKeyRelationin interfaceFieldStrategy- Overrides:
joinKeyRelationin classAbstractFieldStrategytraverse- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
toDataStoreValue
public Object toDataStoreValue(Object val, JDBCStore store)
Description copied from interface:FieldStrategyTranslate 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:
toDataStoreValuein interfaceFieldStrategy- Overrides:
toDataStoreValuein classAbstractFieldStrategy
-
toKeyDataStoreValue
public Object toKeyDataStoreValue(Object val, JDBCStore store)
Description copied from interface:FieldStrategyTranslate 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:
toKeyDataStoreValuein interfaceFieldStrategy- Overrides:
toKeyDataStoreValuein classAbstractFieldStrategy
-
-