com.ebasetech.ufs.utility
Class PersistenceHelper

java.lang.Object
  extended bycom.ebasetech.ufs.utility.PersistenceHelper
All Implemented Interfaces:
PersistenceConstants

public class PersistenceHelper
extends java.lang.Object
implements PersistenceConstants

Singleton Helper class to handle much of the persistence processing for classes in the process package. This class requires that objects that are to be persisted implement Persistent.


Field Summary
private static java.lang.String _dbType
           
private static PersistenceHelper _Instance
           
 
Fields inherited from interface com.ebasetech.ufs.utility.PersistenceConstants
AND, COLON, COMMA, CONNECTION_ERROR, DELETE_ERROR, DELETE_FROM, DESC, ENACTMENT, EQ_QUERY, EQUALS, ERROR_ID, FAILED_CLOSING_CONNECTION, FAILED_CLOSING_RESULTSET, FAILED_CLOSING_STATEMENT, FATAL_JDBC_ERROR, FOR_UPDATE, FROM, GREATER_THAN_QUERY, IN, INSERT_ERROR, INSERT_INTO, ISNULL, JDBC_SQL_ERROR, LE_QUERY, LEFT_OUTER_JOIN, LESS_THAN_QUERY, LIKE_QUERY, LOAD_ERROR, LOCK_ERROR, LPAREN, NO, NOT_EMPTY, OBJECT_ALREADY_MODIFIED, OBJECT_NOT_FOUND_ERROR, ON, OR, ORDER_BY, PERIOD, PLUS_ONE, PRODUCT_NAME_MYSQL, PRODUCT_NAME_ORACLE, PRODUCT_NAME_SQLSERVER, QUERY, QUERY_ERROR, QUOTE, RPAREN, SCRIPT_READ_ERROR, SELECT, SELECT_FROM, SET, SPACE, SQL_ERROR, UPDATE, UPDATE_ERROR, VALUES, WHERE, WILDCARD, WITH_ERROR
 
Constructor Summary
PersistenceHelper()
           
 
Method Summary
 java.lang.String chooseDbSpecificString(com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy, java.lang.String mysqlString, java.lang.String oracleString, java.lang.String sqlserverString)
          Works out from the supplied proxy and table name what sort of database is being accessed and uses that information to choose which of the type-specific strings are required, and returns that string.
 void delete(PersistentDeleteable object, java.sql.Connection con)
          Delete the supplied Persistent object from the repository entirely
 void delete(PersistentDeleteable object, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Delete the supplied Persistent object
 java.sql.Connection getConnection(com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Given a ServletContextProxy, answer the database connection that is available inside it
 java.lang.String getDbType(com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
           
static PersistenceHelper Instance()
          Answer the single instance of PersistenceHelper
 void load(PersistentLoadable object, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Load persistent object using the connection provided
 void lock(PersistentOptimistic object, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          As part of the checks to see if an object is allowed to be updated, lock (using Select for update) the record for the supplied object
 void query(PersistentQueryable queryObject, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Perform the supplied query on the connection provided
 void save(PersistentSaveable object, java.sql.Connection connection)
           
 void save(PersistentSaveable object, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Save an implementation of Persistent to the database
 void update(PersistentUpdateable object, java.sql.Connection con, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Updates the single record for the supplied persistent object
 void update(PersistentUpdateable object, com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          Update an implementation of Persistent to the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_Instance

private static PersistenceHelper _Instance

_dbType

private static java.lang.String _dbType
Constructor Detail

PersistenceHelper

public PersistenceHelper()
Method Detail

Instance

public static PersistenceHelper Instance()
Answer the single instance of PersistenceHelper


save

public void save(PersistentSaveable object,
                 com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          throws PersistenceException
Save an implementation of Persistent to the database

Throws:
PersistenceException

save

public void save(PersistentSaveable object,
                 java.sql.Connection connection)
          throws PersistenceException
Throws:
PersistenceException

load

public void load(PersistentLoadable object,
                 com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          throws PersistenceException
Load persistent object using the connection provided

Throws:
PersistenceException

update

public void update(PersistentUpdateable object,
                   com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
            throws PersistenceException
Update an implementation of Persistent to the database

Throws:
PersistenceException

update

public void update(PersistentUpdateable object,
                   java.sql.Connection con,
                   com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
            throws PersistenceException
Updates the single record for the supplied persistent object

Throws:
PersistenceException

delete

public void delete(PersistentDeleteable object,
                   com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
            throws PersistenceException,
                   java.sql.SQLException
Delete the supplied Persistent object

Throws:
PersistenceException
java.sql.SQLException

delete

public void delete(PersistentDeleteable object,
                   java.sql.Connection con)
            throws PersistenceException
Delete the supplied Persistent object from the repository entirely

Throws:
PersistenceException

getConnection

public java.sql.Connection getConnection(com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
Given a ServletContextProxy, answer the database connection that is available inside it


lock

public void lock(PersistentOptimistic object,
                 com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
          throws ConcurrentUpdateException,
                 PersistenceException
As part of the checks to see if an object is allowed to be updated, lock (using Select for update) the record for the supplied object

Throws:
ConcurrentUpdateException
PersistenceException

query

public void query(PersistentQueryable queryObject,
                  com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
           throws PersistenceException
Perform the supplied query on the connection provided

Throws:
PersistenceException

chooseDbSpecificString

public java.lang.String chooseDbSpecificString(com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy,
                                               java.lang.String mysqlString,
                                               java.lang.String oracleString,
                                               java.lang.String sqlserverString)
                                        throws java.sql.SQLException
Works out from the supplied proxy and table name what sort of database is being accessed and uses that information to choose which of the type-specific strings are required, and returns that string.

Throws:
java.sql.SQLException

getDbType

public java.lang.String getDbType(com.ebasetech.ufs.kernel.IUFSServletContextProxy proxy)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException