Class ColumnVersionStrategy
- java.lang.Object
-
- org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
-
- org.apache.openjpa.jdbc.meta.strats.AbstractVersionStrategy
-
- org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy
-
- All Implemented Interfaces:
java.io.Serializable,Strategy,VersionStrategy
- Direct Known Subclasses:
NumberVersionStrategy,TimestampVersionStrategy
public abstract class ColumnVersionStrategy extends AbstractVersionStrategy
Uses a one or more column(s) and corresponding version object.- Author:
- Marc Prud'hommeaux, Pinaki Poddar
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractVersionStrategy
vers
-
-
Constructor Summary
Constructors Constructor Description ColumnVersionStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancheckVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion)Checks the version of the given state manager with the version stored in memory.protected intcompare(java.lang.Object[] a1, java.lang.Object[] a2)Compare each element of the given arrays that must be of equal size.protected intcompare(java.lang.Object v1, java.lang.Object v2)Compare the two versions.intcompareVersion(java.lang.Object v1, java.lang.Object v2)voiddelete(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.protected abstract intgetJavaType()Return the code fromJavaTypesfor the version values this strategy uses.protected intgetJavaType(int i)Return the code fromJavaTypesfor the version value this given column index uses.voidinsert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)Set values for the mapping into the proper rows.java.lang.Objectload(OpenJPAStateManager sm, JDBCStore store, Result res)Load data.java.lang.Objectload(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins)Load data.voidmap(boolean adapt)Map the owning mapping using this strategy.protected abstract java.lang.ObjectnextVersion(java.lang.Object version)Return the next version given the current one, which may be null.booleanselect(Select sel, ClassMapping mapping)Select the data for this indicator.voidupdate(OpenJPAStateManager sm, JDBCStore store, RowManager rm)Set values for the mapping into the proper rows.-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractVersionStrategy
afterLoad, getBulkUpdateValues, setVersion
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, getAlias, initialize, isCustomDelete, isCustomInsert, isCustomUpdate
-
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, getAlias, initialize, isCustomDelete, isCustomInsert, isCustomUpdate
-
-
-
-
Method Detail
-
getJavaType
protected abstract int getJavaType()
Return the code fromJavaTypesfor the version values this strategy uses. This method is only used during mapping installation.
-
getJavaType
protected int getJavaType(int i)
Return the code fromJavaTypesfor the version value this given column index uses. Only used if the version strategy employs more than one column.
-
nextVersion
protected abstract java.lang.Object nextVersion(java.lang.Object version)
Return the next version given the current one, which may be null.
-
compare
protected int compare(java.lang.Object v1, java.lang.Object v2)Compare the two versions. Defaults to assuming the version objects implementComparable.- See Also:
Comparator.compare(T, T)
-
compare
protected int compare(java.lang.Object[] a1, java.lang.Object[] a2)Compare each element of the given arrays that must be of equal size. The given array values represent version values and the result designate whether first version is earlier, same or later than the second one.- Returns:
- If any element of a1 is later than corresponding element of a2 then returns 1 i.e. the first version is later than the second version. If each element of a1 is equal to corresponding element of a2 then return 0 i.e. the first version is same as the second version. else return a negative number i.e. the first version is earlier than the second version.
-
map
public void map(boolean adapt)
Description copied from interface:StrategyMap the owning mapping using this strategy.- Specified by:
mapin interfaceStrategy- Overrides:
mapin 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
-
insert
public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws java.sql.SQLException
Description copied from interface:StrategySet 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:
insertin interfaceStrategy- Overrides:
insertin classAbstractStrategy- Throws:
java.sql.SQLException
-
update
public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws java.sql.SQLException
Description copied from interface:StrategySet values for the mapping into the proper rows.- Specified by:
updatein interfaceStrategy- Overrides:
updatein 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 sm, JDBCStore store, RowManager rm) throws java.sql.SQLException
Description copied from interface:StrategySet 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:
deletein interfaceStrategy- Overrides:
deletein 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)
-
select
public boolean select(Select sel, ClassMapping mapping)
Description copied from interface:VersionStrategySelect the data for this indicator.- Specified by:
selectin interfaceVersionStrategy- Overrides:
selectin classAbstractVersionStrategymapping- 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
public java.lang.Object load(OpenJPAStateManager sm, JDBCStore store, Result res) throws java.sql.SQLException
Description copied from interface:VersionStrategyLoad data.- Specified by:
loadin interfaceVersionStrategy- Overrides:
loadin classAbstractVersionStrategy- Throws:
java.sql.SQLException
-
load
public java.lang.Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins) throws java.sql.SQLException
Description copied from interface:VersionStrategyLoad data.- Specified by:
loadin interfaceVersionStrategy- Overrides:
loadin classAbstractVersionStrategy- Throws:
java.sql.SQLException
-
checkVersion
public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion) throws java.sql.SQLException
Description copied from interface:VersionStrategyChecks the version of the given state manager with the version stored in memory.- Specified by:
checkVersionin interfaceVersionStrategy- Overrides:
checkVersionin classAbstractVersionStrategy- Returns:
- true if the in-memory version was up-to-date, false otherwise
- Throws:
java.sql.SQLException
-
compareVersion
public int compareVersion(java.lang.Object v1, java.lang.Object v2)- Specified by:
compareVersionin interfaceVersionStrategy- Overrides:
compareVersionin classAbstractVersionStrategy- See Also:
StoreManager.compareVersion(org.apache.openjpa.kernel.OpenJPAStateManager, java.lang.Object, java.lang.Object)
-
-