Class StoreCollectionFieldStrategy
- 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
-
- All Implemented Interfaces:
java.io.Serializable
,FieldStrategy
,Strategy
- Direct Known Subclasses:
HandlerCollectionTableFieldStrategy
,RelationToManyInverseKeyFieldStrategy
,RelationToManyTableFieldStrategy
public abstract class StoreCollectionFieldStrategy extends ContainerFieldStrategy
Base class for strategies that are stored as a collection, even if their field value is something else. Handles data loading and basic query functionality. Subclasses must implement abstract methods and insert/update/delete behavior as well as overridingFieldStrategy.toDataStoreValue(java.lang.Object, org.apache.openjpa.jdbc.kernel.JDBCStore)
,FieldStrategy.join(org.apache.openjpa.jdbc.sql.Joins, boolean)
, andFieldStrategy.joinRelation(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 StoreCollectionFieldStrategy()
-
Method Summary
All Methods Instance Methods Abstract 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.ForeignKey
getJoinForeignKey()
protected abstract 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).boolean
isEagerSelectToMany()
Whether the eager joins or selects used by this field are to-many.protected abstract Joins
join(Joins joins, ClassMapping elem)
Join to the owning field table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).protected abstract Joins
joinElementRelation(Joins joins, ClassMapping elem)
Join this value's table to the table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).void
load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
Load secondary data using a connection from the store manager.void
loadEagerJoin(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)
Load the joined eager result.java.lang.Object
loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object res)
Load the batched eager result.protected abstract java.lang.Object
loadElement(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Load an element of the collection.java.lang.Object
loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Load this field value using the given result.protected abstract Proxy
newLRSProxy()
Return a large result set proxy for this field.protected Joins
selectAll(Select sel, ClassMapping elem, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Select data for loading, starting in field table.void
selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Fill in joined select to related objects.void
selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Fill in parallel eager select for related objects.protected abstract 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.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.ContainerFieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendJoinCount, appendSize, appendUnaliasedJoin, getIndependentElementMappings
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
appendType, assertNotMappedBy, isVersionable, join, joinKey, joinKeyRelation, joinRelation, load, loadKeyProjection, select, setFieldMapping, toDataStoreValue, toKeyDataStoreValue, where
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, delete, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, map, 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.Strategy
customDelete, customInsert, customUpdate, delete, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, map, update
-
-
-
-
Method Detail
-
getJoinForeignKey
protected abstract 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).
-
selectElement
protected abstract 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). Elements of the result will be loaded withloadElement(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)
.
-
loadElement
protected abstract java.lang.Object loadElement(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
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.- Throws:
java.sql.SQLException
-
joinElementRelation
protected abstract Joins joinElementRelation(Joins joins, ClassMapping elem)
Join this value's table to the table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).
-
join
protected abstract Joins join(Joins joins, ClassMapping elem)
Join to the owning field table for the given element mapping fromContainerFieldStrategy.getIndependentElementMappings(boolean)
(or null).
-
newLRSProxy
protected abstract Proxy newLRSProxy()
Return a large result set proxy for this field.
-
toCollection
protected java.util.Collection toCollection(java.lang.Object val)
Convert the field value to a collection. Handles collections and arrays by default.
-
add
protected void add(JDBCStore store, java.lang.Object coll, java.lang.Object obj)
Add an item to the data structure representing a field value. By default, assumes the structure is a collection.
-
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
-
selectEagerParallel
public void selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Description copied from interface:FieldStrategy
Fill in parallel eager select for related objects.- Specified by:
selectEagerParallel
in interfaceFieldStrategy
- Overrides:
selectEagerParallel
in classAbstractFieldStrategy
- See Also:
FieldStrategy.select(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int)
-
selectEagerJoin
public void selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Description copied from interface:FieldStrategy
Fill in joined select to related objects.- Specified by:
selectEagerJoin
in interfaceFieldStrategy
- Overrides:
selectEagerJoin
in classAbstractFieldStrategy
- See Also:
FieldStrategy.select(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int)
-
isEagerSelectToMany
public boolean isEagerSelectToMany()
Description copied from interface:FieldStrategy
Whether the eager joins or selects used by this field are to-many.- Specified by:
isEagerSelectToMany
in interfaceFieldStrategy
- Overrides:
isEagerSelectToMany
in classAbstractFieldStrategy
-
loadEagerParallel
public java.lang.Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object res) throws java.sql.SQLException
Description copied from interface:FieldStrategy
Load the batched eager result.- Specified by:
loadEagerParallel
in interfaceFieldStrategy
- Overrides:
loadEagerParallel
in classAbstractFieldStrategy
res
- originally theResult
to load from, but this method may return a processed result form that will be passed to subsequent calls- Throws:
java.sql.SQLException
-
loadEagerJoin
public void loadEagerJoin(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res) throws java.sql.SQLException
Description copied from interface:FieldStrategy
Load the joined eager result.- Specified by:
loadEagerJoin
in interfaceFieldStrategy
- Overrides:
loadEagerJoin
in classAbstractFieldStrategy
- Throws:
java.sql.SQLException
-
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
-
selectAll
protected Joins selectAll(Select sel, ClassMapping elem, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Select data for loading, starting in field table.
-
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
-
getJoinForeignKey
public ForeignKey getJoinForeignKey()
- Specified by:
getJoinForeignKey
in classContainerFieldStrategy
-
-