Package org.apache.openjpa.jdbc.meta
Class Version
java.lang.Object
org.apache.openjpa.jdbc.meta.Version
- All Implemented Interfaces:
Serializable
,Strategy
,VersionStrategy
,MetaDataContext
,MetaDataModes
Handles optimistic lock versioning for a class.
- Author:
- Abe White
- See Also:
-
Field Summary
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterLoad
(OpenJPAStateManager sm, JDBCStore store) This method is called after data is loaded into the instance, in case the version indicator works off of a state image.boolean
checkVersion
(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) Checks the version of the given state manager with the version stored in memory.void
Clear mapping information, including strategy.int
compareVersion
(Object v1, Object v2) 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.getAlias()
Return the alias of this strategy.Return the owning mapping.I/O information on the version columns.Column[]
Columns used for versioning.getIndex()
Index on the version columns, or null if none.Raw mapping data.Access metadata repository.int
Resolve mode.The strategy used for versioning.void
Perform caching and other initialization operations.void
insert
(OpenJPAStateManager sm, JDBCStore store, RowManager rm) Set values for the mapping into the proper rows.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.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.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.load
(OpenJPAStateManager sm, JDBCStore store, Result res) Load data.load
(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) Load data.void
map
(boolean adapt) Map the owning mapping using this strategy.void
Increment the reference count of used schema components.boolean
resolve
(int mode) Resolve mapping information.boolean
select
(Select sel, ClassMapping mapping) Select the data for this indicator.void
setColumnIO
(ColumnIO io) I/O information on the version columns.void
setColumns
(Column[] cols) Columns used for versioning.void
Index on the version columns, or null if none.void
setResolve
(int mode) Resolve mode.void
setResolve
(int mode, boolean on) Resolve mode.void
setStrategy
(VersionStrategy strategy, Boolean adapt) The strategy used for versioning.void
setVersion
(Version owner) Set the version that uses this strategy.void
UpdateMappingInfo
with our current mapping information.toString()
void
update
(OpenJPAStateManager sm, JDBCStore store, RowManager rm) Set values for the mapping into the proper rows.
-
Constructor Details
-
Version
Constructor. Supply owning mapping.
-
-
Method Details
-
getRepository
Description copied from interface:MetaDataContext
Access metadata repository.- Specified by:
getRepository
in interfaceMetaDataContext
-
getMappingRepository
-
getClassMapping
Return the owning mapping. -
getStrategy
The strategy used for versioning. -
setStrategy
The strategy used for versioning. Theadapt
parameter determines whether to adapt when mapping the strategy; use null if the strategy should not be mapped. -
getMappingInfo
Raw mapping data. -
getColumns
Columns used for versioning. -
setColumns
Columns used for versioning. -
getColumnIO
I/O information on the version columns. -
setColumnIO
I/O information on the version columns. -
getIndex
Index on the version columns, or null if none. -
setIndex
Index on the version columns, or null if none. -
refSchemaComponents
public void refSchemaComponents()Increment the reference count of used schema components. -
clearMapping
public void clearMapping()Clear mapping information, including strategy. -
syncMappingInfo
public void syncMappingInfo()UpdateMappingInfo
with our current mapping information. -
getResolve
public int getResolve()Resolve mode. -
setResolve
public void setResolve(int mode) Resolve mode. -
setResolve
public void setResolve(int mode, boolean on) Resolve mode. -
resolve
public boolean resolve(int mode) Resolve mapping information. -
getAlias
Description copied from interface:Strategy
Return the alias of this strategy. For custom strategies, return the full class name. -
map
public void map(boolean adapt) Description copied from interface:Strategy
Map the owning mapping using this strategy. -
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
-
insert
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
- Throws:
SQLException
-
update
Description copied from interface:Strategy
Set values for the mapping into the proper rows.- Specified by:
update
in interfaceStrategy
- Throws:
SQLException
- See Also:
-
delete
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
- Throws:
SQLException
- See Also:
-
isCustomInsert
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
-
isCustomUpdate
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
-
isCustomDelete
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
-
customInsert
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
- Throws:
SQLException
-
customUpdate
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
- Throws:
SQLException
-
customDelete
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
- Throws:
SQLException
-
setVersion
Description copied from interface:VersionStrategy
Set the version that uses this strategy. This will be called before use.- Specified by:
setVersion
in interfaceVersionStrategy
-
select
Description copied from interface:VersionStrategy
Select the data for this indicator.- Specified by:
select
in interfaceVersionStrategy
mapping
- the known base class being selected; this may not be the base class in the inheritance hierarchy- Returns:
- true if anything was selected; false otherwise
-
load
Description copied from interface:VersionStrategy
Load data.- Specified by:
load
in interfaceVersionStrategy
- Throws:
SQLException
-
load
public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) throws SQLException Description copied from interface:VersionStrategy
Load data.- Specified by:
load
in interfaceVersionStrategy
- Throws:
SQLException
-
afterLoad
Description copied from interface:VersionStrategy
This method is called after data is loaded into the instance, in case the version indicator works off of a state image.- Specified by:
afterLoad
in interfaceVersionStrategy
-
checkVersion
public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) throws SQLException Description copied from interface:VersionStrategy
Checks the version of the given state manager with the version stored in memory.- Specified by:
checkVersion
in interfaceVersionStrategy
- Returns:
- true if the in-memory version was up-to-date, false otherwise
- Throws:
SQLException
-
compareVersion
- Specified by:
compareVersion
in interfaceVersionStrategy
- See Also:
-
toString
-
getBulkUpdateValues
- Specified by:
getBulkUpdateValues
in interfaceVersionStrategy
- Returns:
- a Map<Column,Object> specifying how to update each version column in this instance during a bulk update.
- Since:
- 1.0.0
-