Class RelationMapTableFieldStrategy
- 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.StoreCollectionFieldStrategy
-
- org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy
-
- org.apache.openjpa.jdbc.meta.strats.RelationMapTableFieldStrategy
-
- All Implemented Interfaces:
java.io.Serializable
,FieldStrategy
,Strategy
,LRSMapFieldStrategy
public class RelationMapTableFieldStrategy extends RelationToManyTableFieldStrategy implements LRSMapFieldStrategy
Uses an association table to hold map values. Derives map keys from a field in each value.- 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 RelationMapTableFieldStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
add(JDBCStore store, java.lang.Object coll, java.lang.Object obj)
Add an item to the data structure representing a field value.java.lang.Object
deriveKey(JDBCStore store, java.lang.Object value)
Some mapping derive keys from map values.java.lang.Object
deriveValue(JDBCStore store, java.lang.Object key)
Some mapping derive values from map keys.FieldMapping
getFieldMapping()
The owning field mapping.ClassMapping[]
getIndependentKeyMappings(boolean traverse)
Return all independent mappings to which this strategy must join in order to access map keys, or empty array if none.ClassMapping[]
getIndependentValueMappings(boolean traverse)
Return all independent mappings to which this strategy must join in order to access map values, or empty array if none.ForeignKey
getJoinForeignKey(ClassMapping cls)
Return the foreign key used to join to the owning field for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).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[] joins, 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).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
joinKeyRelation(Joins joins, ClassMapping key)
Join this value's table to the table for the given key mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)
(or null).Joins
joinValueRelation(Joins joins, ClassMapping val)
Join this value's table to the table for the given value mapping fromLRSMapFieldStrategy.getIndependentValueMappings(boolean)
(or null).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.protected Proxy
newLRSProxy()
Return a large result set proxy for this field.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.protected java.util.Collection
toCollection(java.lang.Object val)
Convert the field value to a collection.-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy
delete, getIndependentElementMappings, insert, join, join, joinElementRelation, joinRelation, loadElement, selectElement, toDataStoreValue, update
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy
getJoinForeignKey, isEagerSelectToMany, load, loadEagerJoin, loadEagerParallel, loadProjection, selectAll, selectEagerJoin, selectEagerParallel, 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, isVersionable, load, loadKeyProjection, select, setFieldMapping, toKeyDataStoreValue, where
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, getAlias, initialize, 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, join, joinRelation, load, load, loadEagerJoin, loadEagerParallel, loadKeyProjection, loadProjection, select, selectEagerJoin, selectEagerParallel, setFieldMapping, supportsSelect, toDataStoreValue, toKeyDataStoreValue, where
-
Methods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, delete, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, update
-
-
-
-
Method Detail
-
getFieldMapping
public FieldMapping getFieldMapping()
Description copied from interface:LRSMapFieldStrategy
The owning field mapping.- Specified by:
getFieldMapping
in interfaceLRSMapFieldStrategy
-
getIndependentKeyMappings
public ClassMapping[] getIndependentKeyMappings(boolean traverse)
Description copied from interface:LRSMapFieldStrategy
Return all independent mappings to which this strategy must join in order to access map keys, or empty array if none.- Specified by:
getIndependentKeyMappings
in interfaceLRSMapFieldStrategy
- See Also:
ValueMapping.getIndependentTypeMappings()
,ClassMapping.EMPTY_MAPPINGS
-
getIndependentValueMappings
public ClassMapping[] getIndependentValueMappings(boolean traverse)
Description copied from interface:LRSMapFieldStrategy
Return all independent mappings to which this strategy must join in order to access map values, or empty array if none.- Specified by:
getIndependentValueMappings
in interfaceLRSMapFieldStrategy
- See Also:
ValueMapping.getIndependentTypeMappings()
,ClassMapping.EMPTY_MAPPINGS
-
getJoinForeignKey
public ForeignKey getJoinForeignKey(ClassMapping cls)
Description copied from class:StoreCollectionFieldStrategy
Return the foreign key used to join to the owning field for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).- Specified by:
getJoinForeignKey
in interfaceLRSMapFieldStrategy
- Overrides:
getJoinForeignKey
in classRelationToManyTableFieldStrategy
-
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).- Specified by:
getKeyColumns
in interfaceLRSMapFieldStrategy
-
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).- Specified by:
getValueColumns
in interfaceLRSMapFieldStrategy
-
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.- Specified by:
selectKey
in interfaceLRSMapFieldStrategy
-
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.- Specified by:
loadKey
in interfaceLRSMapFieldStrategy
- Throws:
java.sql.SQLException
-
deriveKey
public java.lang.Object deriveKey(JDBCStore store, java.lang.Object value)
Description copied from interface:LRSMapFieldStrategy
Some mapping derive keys from map values. Other mappings may return null.- Specified by:
deriveKey
in interfaceLRSMapFieldStrategy
-
deriveValue
public java.lang.Object deriveValue(JDBCStore store, java.lang.Object key)
Description copied from interface:LRSMapFieldStrategy
Some mapping derive values from map keys. Other mappings may return null.- Specified by:
deriveValue
in interfaceLRSMapFieldStrategy
-
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)
.- Specified by:
selectValue
in interfaceLRSMapFieldStrategy
-
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.- Specified by:
loadValue
in interfaceLRSMapFieldStrategy
- Throws:
java.sql.SQLException
-
getResults
public Result[] getResults(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, Joins[] joins, 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.- Specified by:
getResults
in interfaceLRSMapFieldStrategy
- Throws:
java.sql.SQLException
-
joinKeyRelation
public Joins joinKeyRelation(Joins joins, ClassMapping key)
Description copied from interface:LRSMapFieldStrategy
Join this value's table to the table for the given key mapping fromLRSMapFieldStrategy.getIndependentKeyMappings(boolean)
(or null).- Specified by:
joinKeyRelation
in interfaceLRSMapFieldStrategy
-
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
-
joinValueRelation
public Joins joinValueRelation(Joins joins, ClassMapping val)
Description copied from interface:LRSMapFieldStrategy
Join this value's table to the table for the given value mapping fromLRSMapFieldStrategy.getIndependentValueMappings(boolean)
(or null).- Specified by:
joinValueRelation
in interfaceLRSMapFieldStrategy
-
newLRSProxy
protected Proxy newLRSProxy()
Description copied from class:StoreCollectionFieldStrategy
Return a large result set proxy for this field.- Specified by:
newLRSProxy
in classStoreCollectionFieldStrategy
-
add
protected void add(JDBCStore store, java.lang.Object coll, java.lang.Object obj)
Description copied from class:StoreCollectionFieldStrategy
Add an item to the data structure representing a field value. By default, assumes the structure is a collection.- Overrides:
add
in classStoreCollectionFieldStrategy
-
toCollection
protected java.util.Collection toCollection(java.lang.Object val)
Description copied from class:StoreCollectionFieldStrategy
Convert the field value to a collection. Handles collections and arrays by default.- Overrides:
toCollection
in classStoreCollectionFieldStrategy
-
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 classRelationToManyTableFieldStrategy
- 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
-
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 interfaceFieldStrategy
- Overrides:
joinKey
in classAbstractFieldStrategy
-
-