Class AbstractFieldStrategy
- java.lang.Object
-
- org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
-
- org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
-
- All Implemented Interfaces:
java.io.Serializable,FieldStrategy,Strategy
- Direct Known Subclasses:
ContainerFieldStrategy,EmbedFieldStrategy,HandlerFieldStrategy,LobFieldStrategy,NoneFieldStrategy,PrimitiveFieldStrategy,RelationFieldStrategy,StringFieldStrategy
public abstract class AbstractFieldStrategy extends AbstractStrategy implements FieldStrategy
No-op strategy for easy extension.- Author:
- Abe White
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected FieldMappingfieldThe owning field mapping.
-
Constructor Summary
Constructors Constructor Description AbstractFieldStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendIndex(SQLBuffer sql, Select sel, Joins joins)Append the ordered column alias to the given statement.voidappendIsEmpty(SQLBuffer sql, Select sel, Joins joins)Append a where clause to the given statement checking if this value is empty.voidappendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins)Append a where clause to the given statement checking if this value is not empty.voidappendIsNotNull(SQLBuffer sql, Select sel, Joins joins)Append a where clause to the given statement checking if this value is not null.voidappendIsNull(SQLBuffer sql, Select sel, Joins joins)Append a where clause to the given statement checking if this value is null.voidappendSize(SQLBuffer sql, Select sel, Joins joins)Append a where clause to the given statement checking the size of the value.voidappendType(SQLBuffer sql, Select sel, Joins joins)Append the entity discriminator value to the given statement.protected voidassertNotMappedBy()Throws an informative exception if the field declares a mapped-by value.booleanisEagerSelectToMany()Whether the eager joins or selects used by this field are to-many.booleanisVersionable()Return true if this field can be used as part of a state image for optimistic locking.Joinsjoin(Joins joins, boolean forceOuter)Join this value to the class table.JoinsjoinKey(Joins joins, boolean forceOuter)Join the key value to the class table.JoinsjoinKeyRelation(Joins joins, boolean forceOuter, boolean traverse)Join this value's table to the table for the related first class object key type, if any.JoinsjoinRelation(Joins joins, boolean forceOuter, boolean traverse)Join this value's table to the table for the related first class object type, if any.voidload(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)Load secondary data using a connection from the store manager.voidload(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.voidloadEagerJoin(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)Load the joined eager result.java.lang.ObjectloadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object res)Load the batched eager result.java.lang.ObjectloadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)Load this field's key value using the given result.java.lang.ObjectloadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)Load this field value using the given result.intselect(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)Select the virtual row columns of this mapping.voidselectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)Fill in joined select to related objects.voidselectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)Fill in parallel eager select for related objects.voidsetFieldMapping(FieldMapping owner)Set the class mapping using this strategy.intsupportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)Return whether this mapping can perform the given select type.java.lang.ObjecttoDataStoreValue(java.lang.Object val, JDBCStore store)Translate the given external field value to its datastore equivalent.java.lang.ObjecttoKeyDataStoreValue(java.lang.Object val, JDBCStore store)Translate the given key value to its datastore equivalent.voidwhere(OpenJPAStateManager sm, JDBCStore store, RowManager rm, java.lang.Object prevValue)Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value.-
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
-
-
-
-
Field Detail
-
field
protected FieldMapping field
The owning field mapping.
-
-
Method Detail
-
assertNotMappedBy
protected void assertNotMappedBy()
Throws an informative exception if the field declares a mapped-by value.
-
setFieldMapping
public void setFieldMapping(FieldMapping owner)
Description copied from interface:FieldStrategySet the class mapping using this strategy. This will be called before use.- Specified by:
setFieldMappingin interfaceFieldStrategy
-
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- See Also:
Select
-
selectEagerJoin
public void selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Description copied from interface:FieldStrategyFill in joined select to related objects.
-
selectEagerParallel
public void selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Description copied from interface:FieldStrategyFill in parallel eager select for related objects.
-
isEagerSelectToMany
public boolean isEagerSelectToMany()
Description copied from interface:FieldStrategyWhether the eager joins or selects used by this field are to-many.- Specified by:
isEagerSelectToManyin interfaceFieldStrategy
-
select
public int select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Description copied from interface:FieldStrategySelect the virtual row columns of this mapping.- Specified by:
selectin interfaceFieldStrategy- Parameters:
sel- the select to add tosm- the instance being loaded, or null if not initialized yet or selecting for multiple instancesstore- the current store managerfetch- fetch configurationeagerMode- the eager fetch mode to use; this may be more restrictive than the mode of the fetch configuration- Returns:
- > 0 if this mapping requires the selected data (if any), 0 if it selected data but does not require it, or < 0 if no data was selected
-
loadEagerParallel
public java.lang.Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object res) throws java.sql.SQLException
Description copied from interface:FieldStrategyLoad the batched eager result.- Specified by:
loadEagerParallelin interfaceFieldStrategyres- originally theResultto 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:FieldStrategyLoad the joined eager result.- Specified by:
loadEagerJoinin interfaceFieldStrategy- Throws:
java.sql.SQLException
-
load
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res) throws java.sql.SQLException
Description copied from interface:FieldStrategyLoad virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.- Specified by:
loadin interfaceFieldStrategy- Throws:
java.sql.SQLException
-
load
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws java.sql.SQLException
Description copied from interface:FieldStrategyLoad secondary data using a connection from the store manager.- Specified by:
loadin interfaceFieldStrategy- Throws:
java.sql.SQLException
-
toDataStoreValue
public java.lang.Object toDataStoreValue(java.lang.Object val, JDBCStore store)Description copied from interface:FieldStrategyTranslate 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:
toDataStoreValuein interfaceFieldStrategy
-
toKeyDataStoreValue
public java.lang.Object toKeyDataStoreValue(java.lang.Object val, JDBCStore store)Description copied from interface:FieldStrategyTranslate the given key 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:
toKeyDataStoreValuein interfaceFieldStrategy
-
appendIsEmpty
public void appendIsEmpty(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend a where clause to the given statement checking if this value is empty. Appends impossible-to-satisfy SQL by default.- Specified by:
appendIsEmptyin interfaceFieldStrategy
-
appendIsNotEmpty
public void appendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend a where clause to the given statement checking if this value is not empty. Appends always-satisfied SQL by default.- Specified by:
appendIsNotEmptyin interfaceFieldStrategy
-
appendIsNull
public void appendIsNull(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend a where clause to the given statement checking if this value is null.- Specified by:
appendIsNullin interfaceFieldStrategy
-
appendIsNotNull
public void appendIsNotNull(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend a where clause to the given statement checking if this value is not null.- Specified by:
appendIsNotNullin interfaceFieldStrategy
-
appendSize
public void appendSize(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend a where clause to the given statement checking the size of the value.- Specified by:
appendSizein interfaceFieldStrategy
-
appendIndex
public void appendIndex(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend the ordered column alias to the given statement.- Specified by:
appendIndexin interfaceFieldStrategy
-
appendType
public void appendType(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategyAppend the entity discriminator value to the given statement.- Specified by:
appendTypein interfaceFieldStrategy
-
join
public Joins join(Joins joins, boolean forceOuter)
Description copied from interface:FieldStrategyJoin this value to the class table. Does nothing by default.- Specified by:
joinin interfaceFieldStrategy
-
joinKey
public Joins joinKey(Joins joins, boolean forceOuter)
Description copied from interface:FieldStrategyJoin the key value to the class table. Does nothing by default.- Specified by:
joinKeyin interfaceFieldStrategy
-
joinRelation
public Joins joinRelation(Joins joins, boolean forceOuter, boolean traverse)
Description copied from interface:FieldStrategyJoin this value's table to the table for the related first class object type, if any. Does nothing by default.- Specified by:
joinRelationin interfaceFieldStrategytraverse- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
joinKeyRelation
public Joins joinKeyRelation(Joins joins, boolean forceOuter, boolean traverse)
Description copied from interface:FieldStrategyJoin this value's table to the table for the related first class object key type, if any. Does nothing by default.- Specified by:
joinKeyRelationin interfaceFieldStrategytraverse- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
loadProjection
public java.lang.Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.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- 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:FieldStrategyLoad this field's key value using the given result. The result will contain the columns fromValueMapping.getColumns().- Specified by:
loadKeyProjectionin interfaceFieldStrategy- Throws:
java.sql.SQLException
-
isVersionable
public boolean isVersionable()
Description copied from interface:FieldStrategyReturn true if this field can be used as part of a state image for optimistic locking.- Specified by:
isVersionablein interfaceFieldStrategy
-
where
public void where(OpenJPAStateManager sm, JDBCStore store, RowManager rm, java.lang.Object prevValue) throws java.sql.SQLException
Description copied from interface:FieldStrategyAdd a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value. Only versionable mappings must implement this method meaningfully.- Specified by:
wherein interfaceFieldStrategy- Throws:
java.sql.SQLException
-
-