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:
java.io.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).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.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
joinKeyRelation(Joins joins, ClassMapping key)
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.java.lang.Object
loadKey(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Load a key from the given result.java.lang.Object
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.java.lang.Object
toDataStoreValue(java.lang.Object val, JDBCStore store)
Translate the given external field value to its datastore equivalent.java.lang.Object
toKeyDataStoreValue(java.lang.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
-
-
-
-
Method Detail
-
getKeyColumns
public Column[] getKeyColumns(ClassMapping cls)
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
public Column[] getValueColumns(ClassMapping cls)
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 java.sql.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:
java.sql.SQLException
-
loadKey
public java.lang.Object loadKey(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.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:
java.sql.SQLException
-
loadValue
public java.lang.Object loadValue(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Description copied from interface:LRSMapFieldStrategy
Load a value from the given result.- Throws:
java.sql.SQLException
-
joinKeyRelation
public Joins joinKeyRelation(Joins joins, ClassMapping key)
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
public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws java.sql.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 interfaceStrategy
- Overrides:
insert
in classAbstractStrategy
- Throws:
java.sql.SQLException
-
update
public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws java.sql.SQLException
Description copied from interface:Strategy
Set values for the mapping into the proper rows.- Specified by:
update
in interfaceStrategy
- Overrides:
update
in classAbstractStrategy
- Throws:
java.sql.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: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
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 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
public java.lang.Object toDataStoreValue(java.lang.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 interfaceFieldStrategy
- Overrides:
toDataStoreValue
in classAbstractFieldStrategy
-
toKeyDataStoreValue
public java.lang.Object toKeyDataStoreValue(java.lang.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 interfaceFieldStrategy
- Overrides:
toKeyDataStoreValue
in classAbstractFieldStrategy
-
-