Class HandlerCollectionTableFieldStrategy
- 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.HandlerCollectionTableFieldStrategy
-
- All Implemented Interfaces:
java.io.Serializable
,FieldStrategy
,Strategy
,LRSCollectionFieldStrategy
public class HandlerCollectionTableFieldStrategy extends StoreCollectionFieldStrategy implements LRSCollectionFieldStrategy
Mapping for a collection of values in a separate table 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 HandlerCollectionTableFieldStrategy()
-
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.Column[]
getElementColumns(ClassMapping elem)
Return the columns holding the data for a collection element for the given element mapping fromLRSCollectionFieldStrategy.getIndependentElementMappings(boolean)
(or null).FieldMapping
getFieldMapping()
The owning field mapping.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.ForeignKey
getJoinForeignKey(ClassMapping elem)
Return the foreign key used to join to the owning field for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(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
join(Joins joins, boolean forceOuter)
Join this value to the class table.protected Joins
join(Joins joins, ClassMapping elem)
Join to the owning field table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).Joins
joinElementRelation(Joins joins, ClassMapping elem)
Join this value's table to the table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).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
loadElement(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Load an element of the collection.void
map(boolean adapt)
Map the owning mapping using this strategy.protected Proxy
newLRSProxy()
Return a large result set proxy for this field.void
selectElement(Select sel, ClassMapping elem, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, Joins joins)
Implement this method to select the elements of this field for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).int
supportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
Return whether this mapping can perform the given select type.java.lang.Object
toDataStoreValue(java.lang.Object val, JDBCStore store)
Translate the given external field 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.StoreCollectionFieldStrategy
add, getJoinForeignKey, isEagerSelectToMany, load, loadEagerJoin, loadEagerParallel, loadProjection, selectAll, selectEagerJoin, selectEagerParallel, toCollection
-
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, joinKey, joinKeyRelation, load, loadKeyProjection, select, setFieldMapping, toKeyDataStoreValue, 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, joinKey, joinKeyRelation, load, load, loadEagerJoin, loadEagerParallel, loadKeyProjection, loadProjection, select, selectEagerJoin, selectEagerParallel, setFieldMapping, toKeyDataStoreValue, where
-
Methods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, getAlias, isCustomDelete, isCustomInsert, isCustomUpdate
-
-
-
-
Method Detail
-
getFieldMapping
public FieldMapping getFieldMapping()
Description copied from interface:LRSCollectionFieldStrategy
The owning field mapping.- Specified by:
getFieldMapping
in interfaceLRSCollectionFieldStrategy
-
getIndependentElementMappings
public 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 interfaceLRSCollectionFieldStrategy
- Specified by:
getIndependentElementMappings
in classContainerFieldStrategy
- Parameters:
traverse
- whether we're traversing through to the related type- See Also:
ValueMapping.getIndependentTypeMappings()
,ClassMapping.EMPTY_MAPPINGS
-
getElementColumns
public Column[] getElementColumns(ClassMapping elem)
Description copied from interface:LRSCollectionFieldStrategy
Return the columns holding the data for a collection element for the given element mapping fromLRSCollectionFieldStrategy.getIndependentElementMappings(boolean)
(or null).- Specified by:
getElementColumns
in interfaceLRSCollectionFieldStrategy
-
getJoinForeignKey
public ForeignKey getJoinForeignKey(ClassMapping elem)
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 interfaceLRSCollectionFieldStrategy
- Specified by:
getJoinForeignKey
in classStoreCollectionFieldStrategy
-
selectElement
public void selectElement(Select sel, ClassMapping elem, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, Joins joins)
Description copied from class:StoreCollectionFieldStrategy
Implement this method to select the elements of this field for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null). Elements of the result will be loaded withStoreCollectionFieldStrategy.loadElement(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:
selectElement
in interfaceLRSCollectionFieldStrategy
- Specified by:
selectElement
in classStoreCollectionFieldStrategy
-
loadElement
public java.lang.Object loadElement(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Description copied from class:StoreCollectionFieldStrategy
Load an element of the collection. The given state manager might be null if the load is for a projection or for processing eager parallel results.- Specified by:
loadElement
in interfaceLRSCollectionFieldStrategy
- Specified by:
loadElement
in classStoreCollectionFieldStrategy
- Throws:
java.sql.SQLException
-
join
protected Joins join(Joins joins, ClassMapping elem)
Description copied from class:StoreCollectionFieldStrategy
Join to the owning field table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).- Specified by:
join
in classStoreCollectionFieldStrategy
-
joinElementRelation
public Joins joinElementRelation(Joins joins, ClassMapping elem)
Description copied from class:StoreCollectionFieldStrategy
Join this value's table to the table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).- Specified by:
joinElementRelation
in interfaceLRSCollectionFieldStrategy
- Specified by:
joinElementRelation
in classStoreCollectionFieldStrategy
- See Also:
FieldMapping.joinRelation(org.apache.openjpa.jdbc.sql.Joins, boolean, boolean)
-
newLRSProxy
protected Proxy newLRSProxy()
Description copied from class:StoreCollectionFieldStrategy
Return a large result set proxy for this field.- Specified by:
newLRSProxy
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 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
-
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)
-
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 classStoreCollectionFieldStrategy
- See Also:
Select
-
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
-
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
-
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
-
-