Package org.apache.openjpa.jdbc.meta
Interface FieldStrategy
-
- All Superinterfaces:
java.io.Serializable
,Strategy
- All Known Subinterfaces:
LRSCollectionFieldStrategy
,LRSMapFieldStrategy
- All Known Implementing Classes:
AbstractFieldStrategy
,ContainerFieldStrategy
,EmbedFieldStrategy
,FieldMapping
,HandlerCollectionTableFieldStrategy
,HandlerFieldStrategy
,HandlerHandlerMapTableFieldStrategy
,HandlerRelationMapTableFieldStrategy
,LobFieldStrategy
,MapTableFieldStrategy
,MaxEmbeddedBlobFieldStrategy
,MaxEmbeddedByteArrayFieldStrategy
,MaxEmbeddedCharArrayFieldStrategy
,MaxEmbeddedClobFieldStrategy
,NoneFieldStrategy
,PrimitiveFieldStrategy
,RelationCollectionInverseKeyFieldStrategy
,RelationCollectionTableFieldStrategy
,RelationFieldStrategy
,RelationHandlerMapTableFieldStrategy
,RelationMapInverseKeyFieldStrategy
,RelationMapTableFieldStrategy
,RelationRelationMapTableFieldStrategy
,RelationToManyInverseKeyFieldStrategy
,RelationToManyTableFieldStrategy
,StoreCollectionFieldStrategy
,StringFieldStrategy
public interface FieldStrategy extends Strategy
Maps a persistent field to the relational schema.- Since:
- 0.4.0
- Author:
- Abe White
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
appendIndex(SQLBuffer sql, Select sel, Joins joins)
Append the ordered column alias to the given statement.void
appendIsEmpty(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is empty.void
appendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is not empty.void
appendIsNotNull(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is not null.void
appendIsNull(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is null.void
appendSize(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking the size of the value.void
appendType(SQLBuffer sql, Select sel, Joins joins)
Append the entity discriminator value to the given statement.boolean
isEagerSelectToMany()
Whether the eager joins or selects used by this field are to-many.boolean
isVersionable()
Return true if this field can be used as part of a state image for optimistic locking.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, boolean forceOuter, boolean traverse)
Join this value's table to the table for the related first class object key type, if any.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.void
load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
Load secondary data using a connection from the store manager.void
load(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.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.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.int
select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Select the virtual row columns of this mapping.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.void
setFieldMapping(FieldMapping owner)
Set the class mapping using this strategy.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.java.lang.Object
toKeyDataStoreValue(java.lang.Object val, JDBCStore store)
Translate the given key value to its datastore equivalent.void
where(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 interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, delete, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, map, update
-
-
-
-
Method Detail
-
setFieldMapping
void setFieldMapping(FieldMapping owner)
Set the class mapping using this strategy. This will be called before use.
-
supportsSelect
int supportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)
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.- See Also:
Select
-
selectEagerParallel
void selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Fill in parallel eager select for related objects.
-
selectEagerJoin
void selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Fill in joined select to related objects.
-
isEagerSelectToMany
boolean isEagerSelectToMany()
Whether the eager joins or selects used by this field are to-many.
-
select
int select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Select the virtual row columns of this mapping.- 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
java.lang.Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object res) throws java.sql.SQLException
Load the batched eager result.- Parameters:
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
void loadEagerJoin(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res) throws java.sql.SQLException
Load the joined eager result.- Throws:
java.sql.SQLException
-
load
void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res) throws java.sql.SQLException
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.- Throws:
java.sql.SQLException
-
load
void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws java.sql.SQLException
Load secondary data using a connection from the store manager.- Throws:
java.sql.SQLException
-
toDataStoreValue
java.lang.Object toDataStoreValue(java.lang.Object val, JDBCStore store)
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.
-
toKeyDataStoreValue
java.lang.Object toKeyDataStoreValue(java.lang.Object val, JDBCStore store)
Translate 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.
-
appendIsEmpty
void appendIsEmpty(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is empty. Appends impossible-to-satisfy SQL by default.
-
appendIsNotEmpty
void appendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is not empty. Appends always-satisfied SQL by default.
-
appendIsNull
void appendIsNull(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is null.
-
appendIsNotNull
void appendIsNotNull(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking if this value is not null.
-
appendSize
void appendSize(SQLBuffer sql, Select sel, Joins joins)
Append a where clause to the given statement checking the size of the value.
-
appendIndex
void appendIndex(SQLBuffer sql, Select sel, Joins joins)
Append the ordered column alias to the given statement.
-
appendType
void appendType(SQLBuffer sql, Select sel, Joins joins)
Append the entity discriminator value to the given statement.
-
join
Joins join(Joins joins, boolean forceOuter)
Join this value to the class table. Does nothing by default.
-
joinKey
Joins joinKey(Joins joins, boolean forceOuter)
Join the key value to the class table. Does nothing by default.
-
joinRelation
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. Does nothing by default.- Parameters:
traverse
- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
joinKeyRelation
Joins joinKeyRelation(Joins joins, boolean forceOuter, boolean traverse)
Join this value's table to the table for the related first class object key type, if any. Does nothing by default.- Parameters:
traverse
- if true, throw proper exception if it is not possible for this mapping to traverse into the related type
-
loadProjection
java.lang.Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Load this field value using the given result. The result will contain the columns fromValueMapping.getColumns()
.- Throws:
java.sql.SQLException
-
loadKeyProjection
java.lang.Object loadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Load this field's key value using the given result. The result will contain the columns fromValueMapping.getColumns()
.- Throws:
java.sql.SQLException
-
isVersionable
boolean isVersionable()
Return true if this field can be used as part of a state image for optimistic locking.
-
where
void where(OpenJPAStateManager sm, JDBCStore store, RowManager rm, java.lang.Object prevValue) throws java.sql.SQLException
Add 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.- Throws:
java.sql.SQLException
-
-