DODS 5.1 API

com.lutris.appserver.server.sql
Class CoreDO

java.lang.Object
  |
  +--com.lutris.appserver.server.sql.CoreDO
All Implemented Interfaces:
java.io.Serializable, Transaction
Direct Known Subclasses:
CloneableDO

public abstract class CoreDO
extends java.lang.Object
implements Transaction, java.io.Serializable

Base class from which the data objects are derived.

Version:
$Revision: 1.2 $
Author:
Kyle Clark
See Also:
Serialized Form

Field Summary
protected  boolean persistent
           
static boolean versioning
           
 
Constructor Summary
CoreDO()
          Public constructor.
CoreDO(java.sql.ResultSet rs)
          Public constructor.
 
Method Summary
 void addToCache()
          This method is invoked whenever an object is added to the cache.
 void deleteFromCache()
          This method is invoked whenever an object is deleted from the cache.
static void disableVersioning()
          Disable use of the version column.
 void evict()
          This method is invoked whenever an object is removed from the cache.
 void executeDelete(DBConnection conn)
          Deletes this object from the database.
 void executeInsert(DBConnection conn)
          Inserts this object into the database.
 void executeUpdate(DBConnection conn)
          Updates the contents of this object in the database.
 void finalizeDelete(boolean success)
          Currently does nothing.
 void finalizeInsert(boolean success)
          Updates the persistent state.
 void finalizeUpdate(boolean success)
          The version number of this object is set to the next version for this object if this object was successfully updated in the database.
abstract  java.sql.PreparedStatement getDeleteStatement(DBConnection conn)
          Returns the statement that can be used to delete this object from the database.
abstract  java.sql.PreparedStatement getInsertStatement(DBConnection conn)
          Returns the statement that can be used to insert this object into the database.
protected  int getNewVersion()
          Returns this object's new version.
 ObjectId getOId()
          Returns this object's identifier.
static java.lang.String getOIdColumnName()
          Returns the object identifier column name.
protected  java.lang.String getTableName()
          Return the name of the table whose rows represent these objects.
abstract  java.sql.PreparedStatement getUpdateStatement(DBConnection conn)
          Returns the statement that can be used to update this object in the database.
protected  int getVersion()
          Returns this object's version.
static java.lang.String getVersionColumnName()
          Returns the version column name.
 boolean isPersistent()
          Returns true if this object is persistent in the database (i.e.
 void refresh()
          This method is invoked whenever object's data needs to be loaded.
protected  void setNewVersion(int newVersion)
          Sets this object's new version number.
protected  void setOId(ObjectId oId)
          Sets this object's identifier.
static void setOIdColumnName(java.lang.String _oidColumnName)
          Sets the object identifier column name.
 void setPersistent(boolean persistent)
          Sets the persistent state for this object.
protected  void setVersion(int version)
          Sets this object's version.
static void setVersionColumnName(java.lang.String _versionColumnName)
          Sets the version column name.
 void updateCache()
          This method is invoked whenever an object is inserted or updated in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versioning

public static boolean versioning

persistent

protected boolean persistent
Constructor Detail

CoreDO

public CoreDO()
Public constructor.


CoreDO

public CoreDO(java.sql.ResultSet rs)
       throws java.sql.SQLException,
              ObjectIdException
Public constructor.

Parameters:
rs - a result set.
Throws:
java.sql.SQLException - if an error occurs while instantiating this object from the result set.
ObjectIdException - if the object id for this object is invalid.
Method Detail

disableVersioning

public static void disableVersioning()
Disable use of the version column.


getOIdColumnName

public static java.lang.String getOIdColumnName()
Returns the object identifier column name.

Returns:
the object identifier column name.

setOIdColumnName

public static void setOIdColumnName(java.lang.String _oidColumnName)
Sets the object identifier column name.


getVersionColumnName

public static java.lang.String getVersionColumnName()
Returns the version column name.

Returns:
the version column name.

setVersionColumnName

public static void setVersionColumnName(java.lang.String _versionColumnName)
Sets the version column name.


getOId

public ObjectId getOId()
Returns this object's identifier.

Returns:
this object's identifier.

setOId

protected void setOId(ObjectId oId)
Sets this object's identifier.

Parameters:
oId - this object's identifier.

setVersion

protected void setVersion(int version)
Sets this object's version.

Parameters:
version - the object's version.

getVersion

protected int getVersion()
Returns this object's version.

Returns:
this object's version.

setNewVersion

protected void setNewVersion(int newVersion)
Sets this object's new version number.

Parameters:
newVersion - this object's next version.

getNewVersion

protected int getNewVersion()
Returns this object's new version.

Returns:
this object's new version.

isPersistent

public boolean isPersistent()
Returns true if this object is persistent in the database (i.e. it has been inserted and not deleted)

Returns:
true if this data object has been inserted into the database.

setPersistent

public void setPersistent(boolean persistent)
Sets the persistent state for this object.

Parameters:
persistent - true if this object is present in persistent store.

getInsertStatement

public abstract java.sql.PreparedStatement getInsertStatement(DBConnection conn)
                                                       throws java.sql.SQLException
Returns the statement that can be used to insert this object into the database.

Parameters:
conn - the database connection.
Returns:
the statement used to insert this object into the database. null if the object cannot be inserted.
Throws:
java.sql.SQLException - If an error occurs.

getUpdateStatement

public abstract java.sql.PreparedStatement getUpdateStatement(DBConnection conn)
                                                       throws java.sql.SQLException
Returns the statement that can be used to update this object in the database.

Parameters:
conn - the database connection.
Returns:
the statement used to update this object in the database. null if the object cannot be updated.
Throws:
java.sql.SQLException - If an error occurs.

getDeleteStatement

public abstract java.sql.PreparedStatement getDeleteStatement(DBConnection conn)
                                                       throws java.sql.SQLException
Returns the statement that can be used to delete this object from the database.

Parameters:
conn - the database connection.
Returns:
the statement used to delete this object from the database. null if the object cannot be deleted.
Throws:
java.sql.SQLException - If an error occurs.

executeInsert

public void executeInsert(DBConnection conn)
                   throws java.sql.SQLException,
                          DBRowUpdateException
Inserts this object into the database.

Specified by:
executeInsert in interface Transaction
Parameters:
conn - the database connection.
Throws:
java.sql.SQLException - if a database access error occurs.
DBRowUpdateException - If a version error occurs.

finalizeInsert

public void finalizeInsert(boolean success)
Updates the persistent state.

Specified by:
finalizeInsert in interface Transaction
Parameters:
success - true if the transaction succeeded and this object was successfully inserted into the database.

executeUpdate

public void executeUpdate(DBConnection conn)
                   throws java.sql.SQLException,
                          DBRowUpdateException
Updates the contents of this object in the database.

Specified by:
executeUpdate in interface Transaction
Parameters:
conn - the database connection.
Throws:
java.sql.SQLException - If a database access error occurs.
DBRowUpdateException - If a version error occurs.

getTableName

protected java.lang.String getTableName()
Return the name of the table whose rows represent these objects. This method should be overridden by derived classes.

Returns:
the name of the table.
See Also:
executeUpdate(com.lutris.appserver.server.sql.DBConnection)

finalizeUpdate

public void finalizeUpdate(boolean success)
The version number of this object is set to the next version for this object if this object was successfully updated in the database.

Specified by:
finalizeUpdate in interface Transaction
Parameters:
success - true if the transaction succeeded and this object was successfully updated in the database.
See Also:
getNewVersion()

executeDelete

public void executeDelete(DBConnection conn)
                   throws java.sql.SQLException
Deletes this object from the database.

Specified by:
executeDelete in interface Transaction
Parameters:
conn - Database connection.
Throws:
java.sql.SQLException - If a database access error occurs.

finalizeDelete

public void finalizeDelete(boolean success)
Currently does nothing.

Specified by:
finalizeDelete in interface Transaction
Parameters:
success - true if the transaction succeeded and this object was successfully deleted from the database.

updateCache

public void updateCache()
This method is invoked whenever an object is inserted or updated in the cache. This is empty method and should be overwritten by subclasses.


deleteFromCache

public void deleteFromCache()
This method is invoked whenever an object is deleted from the cache. This is empty method and should be overwritten by subclasses.


addToCache

public void addToCache()
This method is invoked whenever an object is added to the cache. This is empty method and should be overwritten by subclasses.


evict

public void evict()
This method is invoked whenever an object is removed from the cache. This is empty method and should be overwritten by subclasses.


refresh

public void refresh()
             throws DataObjectException
This method is invoked whenever object's data needs to be loaded. This is empty method and should be overwritten by subclasses.

Throws:
DataObjectException - If a data access error occurs.

DODS 5.1 API