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:
java.io.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 overridingFieldStrategy.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)
, andFieldStrategy.joinKeyRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)
if necessary.- 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 MapTableFieldStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(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.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.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.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()
ForeignKey
getJoinForeignKey(ClassMapping cls)
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 void
handleMappedByForeignKey(boolean adapt)
protected boolean
isTypeUnjoinedSubclass(ValueMapping mapped)
Joins
join(Joins joins, boolean forceOuter)
Join this value to the class table.Joins
joinKey(Joins joins, boolean forceOuter)
Join the key value to the class table.Joins
joinKeyRelation(Joins joins, ClassMapping key)
Joins
joinValueRelation(Joins joins, ClassMapping val)
InvokesFieldStrategy.joinRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)
by default.void
load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
Load secondary data using a connection from the store manager.java.lang.Object
loadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Load this field's key value using the given result.java.lang.Object
loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Load this field value using the given result.void
map(boolean adapt)
Map the owning mapping using this strategy.protected boolean
populateKey(Row row, OpenJPAStateManager valsm, java.lang.Object obj, StoreContext ctx, RowManager rm, JDBCStore store)
int
supportsSelect(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, appendUnaliasedJoin
-
Methods 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, where
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, update
-
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, joinKeyRelation, joinRelation, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, toDataStoreValue, toKeyDataStoreValue, where
-
Methods inherited from interface org.apache.openjpa.jdbc.meta.strats.LRSMapFieldStrategy
getKeyColumns, getResults, getValueColumns, loadKey, loadValue, selectKey, selectValue
-
Methods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, 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 interface:LRSMapFieldStrategy
Return 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:
getJoinForeignKey
in interfaceLRSMapFieldStrategy
-
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
-
joinKeyRelation
public Joins joinKeyRelation(Joins joins, ClassMapping key)
InvokesFieldStrategy.joinKeyRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)
by default.- Specified by:
joinKeyRelation
in interfaceLRSMapFieldStrategy
-
joinValueRelation
public Joins joinValueRelation(Joins joins, ClassMapping val)
InvokesFieldStrategy.joinRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)
by default.- Specified by:
joinValueRelation
in interfaceLRSMapFieldStrategy
-
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 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
public void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws java.sql.SQLException
Description copied from interface:Strategy
Set 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:
delete
in interfaceStrategy
- Overrides:
delete
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)
-
supportsSelect
public int supportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
Description copied from interface:FieldStrategy
Return 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:
supportsSelect
in interfaceFieldStrategy
- Overrides:
supportsSelect
in classAbstractFieldStrategy
- See Also:
Select
-
load
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws java.sql.SQLException
Description copied from interface:FieldStrategy
Load secondary data using a connection from the store manager.- Specified by:
load
in interfaceFieldStrategy
- Overrides:
load
in classAbstractFieldStrategy
- Throws:
java.sql.SQLException
-
loadKeyProjection
public java.lang.Object loadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Description copied from interface:FieldStrategy
Load this field's key value using the given result. The result will contain the columns fromValueMapping.getColumns()
.- Specified by:
loadKeyProjection
in interfaceFieldStrategy
- Overrides:
loadKeyProjection
in classAbstractFieldStrategy
- Throws:
java.sql.SQLException
-
loadProjection
public java.lang.Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Description copied from interface:FieldStrategy
Load this field value using the given result. The result will contain the columns fromValueMapping.getColumns()
.- Specified by:
loadProjection
in interfaceFieldStrategy
- Overrides:
loadProjection
in classAbstractFieldStrategy
- Throws:
java.sql.SQLException
-
join
public Joins join(Joins joins, boolean forceOuter)
Description copied from interface:FieldStrategy
Join this value to the class table. Does nothing by default.- Specified by:
join
in interfaceFieldStrategy
- Overrides:
join
in classAbstractFieldStrategy
-
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
-
getJoinForeignKey
public ForeignKey getJoinForeignKey()
- Specified by:
getJoinForeignKey
in classContainerFieldStrategy
-
getIndependentElementMappings
protected ClassMapping[] getIndependentElementMappings(boolean traverse)
Description copied from class:ContainerFieldStrategy
Return all independent mappings to which this strategy must join in order to access collection elements, or empty array if none.- Specified by:
getIndependentElementMappings
in classContainerFieldStrategy
- Parameters:
traverse
- whether we're traversing through to the related type- See Also:
ValueMapping.getIndependentTypeMappings()
,ClassMapping.EMPTY_MAPPINGS
-
handleMappedByForeignKey
protected void handleMappedByForeignKey(boolean adapt)
-
isTypeUnjoinedSubclass
protected boolean isTypeUnjoinedSubclass(ValueMapping mapped)
-
populateKey
protected boolean populateKey(Row row, OpenJPAStateManager valsm, java.lang.Object obj, StoreContext ctx, RowManager rm, JDBCStore store) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-