org.apache.openjpa.jdbc.meta.strats
Class ColumnVersionStrategy

java.lang.Object
  extended by org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
      extended by org.apache.openjpa.jdbc.meta.strats.AbstractVersionStrategy
          extended by org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy
All Implemented Interfaces:
Serializable, Strategy, VersionStrategy
Direct Known Subclasses:
NumberVersionStrategy, TimestampVersionStrategy

public abstract class ColumnVersionStrategy
extends AbstractVersionStrategy

Uses a single column and corresponding version object.

Author:
Marc Prud'hommeaux
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractVersionStrategy
vers
 
Constructor Summary
ColumnVersionStrategy()
           
 
Method Summary
 boolean checkVersion(OpenJPAStateManager sm, JDBCStore store, boolean updateVersion)
          Checks the version of the given state manager with the version stored in memory.
protected  int compare(Object v1, Object v2)
          Compare the two versions.
 int compareVersion(Object v1, Object v2)
           
 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.
protected abstract  int getJavaType()
          Return the code from JavaTypes for the version values this strategy uses.
 void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Set values for the mapping into the proper rows.
 void load(OpenJPAStateManager sm, JDBCStore store, Result res)
          Load data.
 void map(boolean adapt)
          Map the owning mapping using this strategy.
protected abstract  Object nextVersion(Object version)
          Return the next version given the current one, which may be null.
 boolean select(Select sel, ClassMapping mapping)
          Select the data for this indicator.
 void update(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
 

Constructor Detail

ColumnVersionStrategy

public ColumnVersionStrategy()
Method Detail

getJavaType

protected abstract int getJavaType()
Return the code from JavaTypes for the version values this strategy uses. This method is only used during mapping installation.


nextVersion

protected abstract Object nextVersion(Object version)
Return the next version given the current one, which may be null.


compare

protected int compare(Object v1,
                      Object v2)
Compare the two versions. Defaults to assuming the version objects implement Comparable.

See Also:
Comparator.compare(T, T)

map

public void map(boolean adapt)
Description copied from interface: Strategy
Map the owning mapping using this strategy.

Specified by:
map in interface Strategy
Overrides:
map in class AbstractStrategy
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 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 interface Strategy
Overrides:
insert in class AbstractStrategy
Throws:
SQLException

update

public void update(OpenJPAStateManager sm,
                   JDBCStore store,
                   RowManager rm)
            throws SQLException
Description copied from interface: Strategy
Set values for the mapping into the proper rows.

Specified by:
update in interface Strategy
Overrides:
update in class AbstractStrategy
Throws:
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 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 interface Strategy
Overrides:
delete in class AbstractStrategy
Throws:
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: VersionStrategy
Select the data for this indicator.

Specified by:
select in interface VersionStrategy
Overrides:
select in class AbstractVersionStrategy
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

public void load(OpenJPAStateManager sm,
                 JDBCStore store,
                 Result res)
          throws SQLException
Description copied from interface: VersionStrategy
Load data.

Specified by:
load in interface VersionStrategy
Overrides:
load in class AbstractVersionStrategy
Throws:
SQLException

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 interface VersionStrategy
Overrides:
checkVersion in class AbstractVersionStrategy
Returns:
true if the in-memory version was up-to-date, false otherwise
Throws:
SQLException

compareVersion

public int compareVersion(Object v1,
                          Object v2)
Specified by:
compareVersion in interface VersionStrategy
Overrides:
compareVersion in class AbstractVersionStrategy
See Also:
StoreManager.compareVersion(org.apache.openjpa.kernel.OpenJPAStateManager, java.lang.Object, java.lang.Object)


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.