Class MapTableFieldStrategy
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
- All Implemented Interfaces:
Serializable,FieldStrategy,Strategy,LRSMapFieldStrategy
- Direct Known Subclasses:
HandlerHandlerMapTableFieldStrategy,HandlerRelationMapTableFieldStrategy,RelationHandlerMapTableFieldStrategy,RelationRelationMapTableFieldStrategy
public abstract class MapTableFieldStrategy
extends ContainerFieldStrategy
implements LRSMapFieldStrategy
Base class for map mappings. Handles managing the secondary table
used to hold map keys and values and loading. Subclasses must implement
abstract methods and insert/update behavior as well as overriding
FieldStrategy.toDataStoreValue(java.lang.Object, org.apache.openjpa.jdbc.kernel.JDBCStore),
FieldStrategy.toKeyDataStoreValue(java.lang.Object, org.apache.openjpa.jdbc.kernel.JDBCStore),
FieldStrategy.joinRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean), and
FieldStrategy.joinKeyRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean) if necessary.- Author:
- Abe White
- See Also:
-
Field Summary
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
field -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(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.Some mapping derive keys from map values.deriveValue(JDBCStore store, Object key) Some mapping derive values from map keys.The owning field mapping.protected ClassMapping[]getIndependentElementMappings(boolean traverse) Return all independent mappings to which this strategy must join in order to access collection elements, or empty array if none.getIndependentKeyMappings(boolean traverse) Return all independent mappings to which this strategy must join in order to access map keys, or empty array if none.getIndependentValueMappings(boolean traverse) Return all independent mappings to which this strategy must join in order to access map values, or empty array if none.Return the foreign key used to join to the owning field for the given mapping from eitherLRSMapFieldStrategy.getIndependentKeyMappings(boolean)orLRSMapFieldStrategy.getIndependentValueMappings(boolean)(or null).protected voidhandleMappedByForeignKey(boolean adapt) protected booleanisTypeUnjoinedSubclass(ValueMapping mapped) Join this value to the class table.Join the key value to the class table.joinKeyRelation(Joins joins, ClassMapping key) joinValueRelation(Joins joins, ClassMapping val) InvokesFieldStrategy.joinRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)by default.voidload(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) Load secondary data using a connection from the store manager.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.voidmap(boolean adapt) Map the owning mapping using this strategy.protected booleanpopulateKey(Row row, OpenJPAStateManager valsm, Object obj, StoreContext ctx, RowManager rm, JDBCStore store) intsupportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) Return whether this mapping can perform the given select type.Methods inherited from class org.apache.openjpa.jdbc.meta.strats.ContainerFieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendJoinCount, appendSize, appendUnaliasedJoinMethods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
appendType, assertNotMappedBy, isEagerSelectToMany, isVersionable, joinKeyRelation, joinRelation, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, toDataStoreValue, toKeyDataStoreValue, whereMethods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.openjpa.jdbc.meta.FieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendSize, appendType, isEagerSelectToMany, isVersionable, joinKeyRelation, joinRelation, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, toDataStoreValue, toKeyDataStoreValue, whereMethods inherited from interface org.apache.openjpa.jdbc.meta.strats.LRSMapFieldStrategy
getKeyColumns, getResults, getValueColumns, loadKey, loadValue, selectKey, selectValueMethods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, update
-
Constructor Details
-
MapTableFieldStrategy
public MapTableFieldStrategy()
-
-
Method Details
-
getFieldMapping
Description copied from interface:LRSMapFieldStrategyThe owning field mapping.- Specified by:
getFieldMappingin interfaceLRSMapFieldStrategy
-
getIndependentKeyMappings
Description copied from interface:LRSMapFieldStrategyReturn all independent mappings to which this strategy must join in order to access map keys, or empty array if none.- Specified by:
getIndependentKeyMappingsin interfaceLRSMapFieldStrategy- See Also:
-
getIndependentValueMappings
Description copied from interface:LRSMapFieldStrategyReturn all independent mappings to which this strategy must join in order to access map values, or empty array if none.- Specified by:
getIndependentValueMappingsin interfaceLRSMapFieldStrategy- See Also:
-
getJoinForeignKey
Description copied from interface:LRSMapFieldStrategyReturn the foreign key used to join to the owning field for the given mapping from eitherLRSMapFieldStrategy.getIndependentKeyMappings(boolean)orLRSMapFieldStrategy.getIndependentValueMappings(boolean)(or null).- Specified by:
getJoinForeignKeyin interfaceLRSMapFieldStrategy
-
deriveKey
Description copied from interface:LRSMapFieldStrategySome mapping derive keys from map values. Other mappings may return null.- Specified by:
deriveKeyin interfaceLRSMapFieldStrategy
-
deriveValue
Description copied from interface:LRSMapFieldStrategySome mapping derive values from map keys. Other mappings may return null.- Specified by:
deriveValuein interfaceLRSMapFieldStrategy
-
joinKeyRelation
InvokesFieldStrategy.joinKeyRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)by default.- Specified by:
joinKeyRelationin interfaceLRSMapFieldStrategy
-
joinValueRelation
InvokesFieldStrategy.joinRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)by default.- Specified by:
joinValueRelationin interfaceLRSMapFieldStrategy
-
map
public void map(boolean adapt) Description copied from interface:StrategyMap the owning mapping using this strategy.- Specified by:
mapin interfaceStrategy- Overrides:
mapin classAbstractStrategy- 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
-
delete
Description copied from interface:StrategySet 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:
deletein interfaceStrategy- Overrides:
deletein classAbstractStrategy- Throws:
SQLException- See Also:
-
supportsSelect
public int supportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) Description copied from interface:FieldStrategyReturn 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:
supportsSelectin interfaceFieldStrategy- Overrides:
supportsSelectin classAbstractFieldStrategy- See Also:
-
load
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException Description copied from interface:FieldStrategyLoad secondary data using a connection from the store manager.- Specified by:
loadin interfaceFieldStrategy- Overrides:
loadin classAbstractFieldStrategy- Throws:
SQLException
-
loadKeyProjection
public Object loadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws SQLException Description copied from interface:FieldStrategyLoad this field's key value using the given result. The result will contain the columns fromValueMapping.getColumns().- Specified by:
loadKeyProjectionin interfaceFieldStrategy- Overrides:
loadKeyProjectionin classAbstractFieldStrategy- Throws:
SQLException
-
loadProjection
public Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws SQLException Description copied from interface:FieldStrategyLoad this field value using the given result. The result will contain the columns fromValueMapping.getColumns().- Specified by:
loadProjectionin interfaceFieldStrategy- Overrides:
loadProjectionin classAbstractFieldStrategy- Throws:
SQLException
-
join
Description copied from interface:FieldStrategyJoin this value to the class table. Does nothing by default.- Specified by:
joinin interfaceFieldStrategy- Overrides:
joinin classAbstractFieldStrategy
-
joinKey
Description copied from interface:FieldStrategyJoin the key value to the class table. Does nothing by default.- Specified by:
joinKeyin interfaceFieldStrategy- Overrides:
joinKeyin classAbstractFieldStrategy
-
getJoinForeignKey
- Specified by:
getJoinForeignKeyin classContainerFieldStrategy
-
getIndependentElementMappings
Description copied from class:ContainerFieldStrategyReturn all independent mappings to which this strategy must join in order to access collection elements, or empty array if none.- Specified by:
getIndependentElementMappingsin classContainerFieldStrategy- Parameters:
traverse- whether we're traversing through to the related type- See Also:
-
handleMappedByForeignKey
protected void handleMappedByForeignKey(boolean adapt) -
isTypeUnjoinedSubclass
-
populateKey
protected boolean populateKey(Row row, OpenJPAStateManager valsm, Object obj, StoreContext ctx, RowManager rm, JDBCStore store) throws SQLException - Throws:
SQLException
-