Last update: 2011-06-23

org.proteios.core
Class UpdateToSchemaVersionTmpl

java.lang.Object
  extended by org.proteios.core.AbstractUpdateToSchemaVersion
      extended by org.proteios.core.UpdateToSchemaVersionTmpl
All Implemented Interfaces:
UpdateToSchemaVersionInterface

public final class UpdateToSchemaVersionTmpl
extends AbstractUpdateToSchemaVersion
implements UpdateToSchemaVersionInterface

This class is a template for a class that contains methods used to perform incremental update from one schema version to the next. The sub-string "Tmpl" in the class name should be exchanged for the schemaVersion number the class updates to, e.g. UpdateToSchemaVersion27.java for a class that performs an incremental update of the database from schemaVersion 26 to 27. Instructions for using the template class: 1. Make a copy of this java file and name the copy UpdateToSchemaVersion#.java, where the '#' is replaced by the schemaVersion number the class updates to. 2. Set the value of constant UPDATE_SCHEMA_VERSION to this schemaVersion number. 3. Put necessary code to update or adapt existing database items in the body of methods updateToNewSchemaVersion() and adjustItemsToNewSchemaVersion(), respectively. Based on BASE2 class src/core/net/sf/basedb/core/Update.java, but adapted to use a main updater class that performs a general update by calling methods in classes that perform an incremental update from one version to the next.

Version:
2.0
Author:
Olle
Last modified
$Date: 2007-02-13 10:14:33Z $

Constructor Summary
UpdateToSchemaVersionTmpl()
           
 
Method Summary
protected  int adjustItemsToNewSchemaVersion(org.hibernate.Session session)
          Adjust the existing items in the database to be compatible with the latest mappings corresponding to this class.
 int getUpdateSchemaVersion()
          Get the update schema version.
protected  int updateToNewSchemaVersion(org.hibernate.Session session)
          Updates the database to the version corresponding to this class.
 
Methods inherited from class org.proteios.core.AbstractUpdateToSchemaVersion
adjustExistingItems, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.proteios.core.UpdateToSchemaVersionInterface
adjustExistingItems, update
 

Constructor Detail

UpdateToSchemaVersionTmpl

public UpdateToSchemaVersionTmpl()
Method Detail

getUpdateSchemaVersion

public int getUpdateSchemaVersion()
Get the update schema version.

Specified by:
getUpdateSchemaVersion in class AbstractUpdateToSchemaVersion
Returns:
int the update schema version.

updateToNewSchemaVersion

protected int updateToNewSchemaVersion(org.hibernate.Session session)
                                throws BaseException
Updates the database to the version corresponding to this class.

Specified by:
updateToNewSchemaVersion in class AbstractUpdateToSchemaVersion
Parameters:
session - org.hibernate.Session the Hibernate session to use.
Returns:
int The number of affected items.
Throws:
BaseException

adjustItemsToNewSchemaVersion

protected int adjustItemsToNewSchemaVersion(org.hibernate.Session session)
                                     throws BaseException
Adjust the existing items in the database to be compatible with the latest mappings corresponding to this class.

Specified by:
adjustItemsToNewSchemaVersion in class AbstractUpdateToSchemaVersion
Parameters:
session - org.hibernate.Session the Hibernate session to use.
Returns:
int The number of affected items.
Throws:
BaseException

Last update: 2011-06-23