Class EmbedFieldStrategy
- java.lang.Object
-
- org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
-
- org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
-
- org.apache.openjpa.jdbc.meta.strats.EmbedFieldStrategy
-
- All Implemented Interfaces:
java.io.Serializable
,Embeddable
,FieldStrategy
,Strategy
public class EmbedFieldStrategy extends AbstractFieldStrategy implements Embeddable
Mapping for an embedded persistent object.- Since:
- 0.4.0
- Author:
- Abe White
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
field
-
Fields inherited from interface org.apache.openjpa.jdbc.meta.Embeddable
UNSUPPORTED
-
-
Constructor Summary
Constructors Constructor Description EmbedFieldStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
customDelete(OpenJPAStateManager sm, JDBCStore store)
Override this method to customize flushing this mapping.void
customInsert(OpenJPAStateManager sm, JDBCStore store)
Override this method to customize flushing this mapping.void
customUpdate(OpenJPAStateManager sm, JDBCStore store)
Override this method to customize flushing this mapping.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.void
delete(OpenJPAStateManager owner, OpenJPAStateManager sm, JDBCStore store, RowManager rm, Row row)
Delete an embedded object record.ColumnIO
getColumnIO()
Return column I/O information for this mapping.Column[]
getColumns()
Return the columns used by this strategy.java.lang.Object[]
getResultArguments()
Return the arguments needed to extract datastore values viaResult.getObject(java.lang.Object, int, java.lang.Object)
for each column.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.void
insert(OpenJPAStateManager owner, OpenJPAStateManager sm, JDBCStore store, RowManager rm, Row row)
Insert an embedded object.java.lang.Boolean
isCustomDelete(OpenJPAStateManager sm, JDBCStore store)
ReturnBoolean.FALSE
if this mapping does not customize the delete process,Boolean.TRUE
if it does, or null if it does customize the delete, but also relies on the standard delete method being called.java.lang.Boolean
isCustomInsert(OpenJPAStateManager sm, JDBCStore store)
ReturnBoolean.FALSE
if this mapping does not customize the insert process,Boolean.TRUE
if it does, or null if it does customize the insert, but also relies on the standard insert method being called.java.lang.Boolean
isCustomUpdate(OpenJPAStateManager sm, JDBCStore store)
ReturnBoolean.FALSE
if this mapping does not customize the update process,Boolean.TRUE
if it does, or null if it does customize the update, but also relies on the standard update method being called.Joins
join(Joins joins, boolean forceOuter)
Join this value to the class table.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
loadEmbedded(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object val)
Load this strategy's field by transforming the given datastore value.java.lang.Object
loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
Loading embed object without instantiating owner entityvoid
map(boolean adapt)
Map the owning mapping using this strategy.int
select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Select the virtual row columns of this mapping.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
toEmbeddedDataStoreValue(java.lang.Object val, JDBCStore store)
Convert the given Java value to its datastore equivalent.java.lang.Object
toEmbeddedObjectValue(java.lang.Object val)
Convert the given datastore value to its Java equivalent.void
update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
Set values for the mapping into the proper rows.void
update(OpenJPAStateManager owner, OpenJPAStateManager sm, JDBCStore store, RowManager rm, Row row)
Update an embedded object.-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendSize, appendType, assertNotMappedBy, isEagerSelectToMany, isVersionable, joinKey, joinKeyRelation, joinRelation, load, loadEagerJoin, loadEagerParallel, loadKeyProjection, selectEagerJoin, selectEagerParallel, setFieldMapping, toKeyDataStoreValue, where
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
getAlias
-
-
-
-
Method Detail
-
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
-
insert
public void insert(OpenJPAStateManager owner, OpenJPAStateManager sm, JDBCStore store, RowManager rm, Row row) throws java.sql.SQLException
Insert an embedded object.- Parameters:
owner
- the owning state managersm
- the embedded state manager, or null if the value is nullrm
- the row managerrow
- expected row for this embedded value- 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)
-
update
public void update(OpenJPAStateManager owner, OpenJPAStateManager sm, JDBCStore store, RowManager rm, Row row) throws java.sql.SQLException
Update an embedded object.- Parameters:
owner
- the owning state managersm
- the embedded state manager, or null if the value is nullrm
- the row managerrow
- expected row for this embedded value- Throws:
java.sql.SQLException
-
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)
-
delete
public void delete(OpenJPAStateManager owner, OpenJPAStateManager sm, JDBCStore store, RowManager rm, Row row) throws java.sql.SQLException
Delete an embedded object record.- Parameters:
owner
- the owning state managersm
- the embedded state manager, or null if not knownrm
- the row managerrow
- expected row for this embedded value- Throws:
java.sql.SQLException
-
isCustomInsert
public java.lang.Boolean isCustomInsert(OpenJPAStateManager sm, JDBCStore store)
Description copied from interface:Strategy
ReturnBoolean.FALSE
if this mapping does not customize the insert process,Boolean.TRUE
if it does, or null if it does customize the insert, but also relies on the standard insert method being called. Implement theStrategy.customInsert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method to implement the custom insertion behavior.- Specified by:
isCustomInsert
in interfaceStrategy
- Overrides:
isCustomInsert
in classAbstractStrategy
-
isCustomUpdate
public java.lang.Boolean isCustomUpdate(OpenJPAStateManager sm, JDBCStore store)
Description copied from interface:Strategy
ReturnBoolean.FALSE
if this mapping does not customize the update process,Boolean.TRUE
if it does, or null if it does customize the update, but also relies on the standard update method being called. Implement theStrategy.customUpdate(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method to override the default update behavior.- Specified by:
isCustomUpdate
in interfaceStrategy
- Overrides:
isCustomUpdate
in classAbstractStrategy
-
isCustomDelete
public java.lang.Boolean isCustomDelete(OpenJPAStateManager sm, JDBCStore store)
Description copied from interface:Strategy
ReturnBoolean.FALSE
if this mapping does not customize the delete process,Boolean.TRUE
if it does, or null if it does customize the delete, but also relies on the standard delete method being called. Implement theStrategy.customDelete(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore)
method to override the default deletion behavior.- Specified by:
isCustomDelete
in interfaceStrategy
- Overrides:
isCustomDelete
in classAbstractStrategy
-
customInsert
public void customInsert(OpenJPAStateManager sm, JDBCStore store) throws java.sql.SQLException
Description copied from interface:Strategy
Override this method to customize flushing this mapping. For classes, this method must also flush all fields. For fields, this method is called after the owning object is inserted, so if this field is in a row with other fields, that row will already exist.- Specified by:
customInsert
in interfaceStrategy
- Overrides:
customInsert
in classAbstractStrategy
- Throws:
java.sql.SQLException
-
customUpdate
public void customUpdate(OpenJPAStateManager sm, JDBCStore store) throws java.sql.SQLException
Description copied from interface:Strategy
Override this method to customize flushing this mapping. For classes, this method must also flush all fields.- Specified by:
customUpdate
in interfaceStrategy
- Overrides:
customUpdate
in classAbstractStrategy
- Throws:
java.sql.SQLException
-
customDelete
public void customDelete(OpenJPAStateManager sm, JDBCStore store) throws java.sql.SQLException
Description copied from interface:Strategy
Override this method to customize flushing this mapping. For classes, this method must also flush all fields. For fields, this method will be called after the owning object is deleted.- Specified by:
customDelete
in interfaceStrategy
- Overrides:
customDelete
in classAbstractStrategy
- Throws:
java.sql.SQLException
-
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
-
select
public int select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)
Description copied from interface:FieldStrategy
Select the virtual row columns of this mapping.- Specified by:
select
in interfaceFieldStrategy
- Overrides:
select
in classAbstractFieldStrategy
- 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
-
load
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res) throws java.sql.SQLException
Description copied from interface:FieldStrategy
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.- Specified by:
load
in interfaceFieldStrategy
- Overrides:
load
in classAbstractFieldStrategy
- Throws:
java.sql.SQLException
-
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
-
appendIsNull
public void appendIsNull(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategy
Append a where clause to the given statement checking if this value is null.- Specified by:
appendIsNull
in interfaceFieldStrategy
- Overrides:
appendIsNull
in classAbstractFieldStrategy
-
appendIsNotNull
public void appendIsNotNull(SQLBuffer sql, Select sel, Joins joins)
Description copied from interface:FieldStrategy
Append a where clause to the given statement checking if this value is not null.- Specified by:
appendIsNotNull
in interfaceFieldStrategy
- Overrides:
appendIsNotNull
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
-
loadProjection
public java.lang.Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins) throws java.sql.SQLException
Loading embed object without instantiating owner entity- Specified by:
loadProjection
in interfaceFieldStrategy
- Overrides:
loadProjection
in classAbstractFieldStrategy
- Throws:
java.sql.SQLException
-
getColumns
public Column[] getColumns()
Description copied from interface:Embeddable
Return the columns used by this strategy.- Specified by:
getColumns
in interfaceEmbeddable
-
getColumnIO
public ColumnIO getColumnIO()
Description copied from interface:Embeddable
Return column I/O information for this mapping.- Specified by:
getColumnIO
in interfaceEmbeddable
-
getResultArguments
public java.lang.Object[] getResultArguments()
Description copied from interface:Embeddable
Return the arguments needed to extract datastore values viaResult.getObject(java.lang.Object, int, java.lang.Object)
for each column.- Specified by:
getResultArguments
in interfaceEmbeddable
-
toEmbeddedDataStoreValue
public java.lang.Object toEmbeddedDataStoreValue(java.lang.Object val, JDBCStore store)
Description copied from interface:Embeddable
Convert the given Java value to its datastore equivalent. If this mapping occupies multiple columns, return an object array with one element per column. For relation id columns, return the state manager the column depends on.- Specified by:
toEmbeddedDataStoreValue
in interfaceEmbeddable
-
toEmbeddedObjectValue
public java.lang.Object toEmbeddedObjectValue(java.lang.Object val)
Description copied from interface:Embeddable
Convert the given datastore value to its Java equivalent. IfEmbeddable.getColumns()
returns multiple columns, the given datastore value will be an object array of the corresponding length. This method must only be supported by mappings of embedded id objects. In other casesEmbeddable.loadEmbedded(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, java.lang.Object)
will be used instead. ReturnEmbeddable.UNSUPPORTED
if this mapping cannot support this method.- Specified by:
toEmbeddedObjectValue
in interfaceEmbeddable
-
loadEmbedded
public void loadEmbedded(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, java.lang.Object val) throws java.sql.SQLException
Description copied from interface:Embeddable
Load this strategy's field by transforming the given datastore value. IfEmbeddable.getColumns()
returns multiple columns, the given datastore value will be an object array of the corresponding length. The value does not have to be loaded immediately; it may be stored as impl data.- Specified by:
loadEmbedded
in interfaceEmbeddable
- Throws:
java.sql.SQLException
-
-