Expresso 5-6

com.jcorporate.expresso.core.dbobj
Class DBSequence

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
              extended bycom.jcorporate.expresso.core.dbobj.SecuredDBObject
                  extended bycom.jcorporate.expresso.core.dbobj.DBSequence
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable

public abstract class DBSequence
extends SecuredDBObject

DBSequence is a special DBObject that wraps a database sequence. Currently, this class only works with PostgreSQL sequences, but it should be easy to add support for Oracle or others (see createTable() and retrieve() methods specifically). If you attempt to use this with a database other than PostgreSQL, it will throw an exception.

To make this compatible with the the schema autocreation of DBObjects magic, security scheme, etc., this class subclasses DBObject. But there are many methods that have been overriden, because they do not make sense for a sequence (ex: search, clear, etc). If these methods are called, an exception is thrown.

To get the next value in the sequence, call getNext().

make sure that you override the setupFields() method and supply the proper setup parameters.

ex:

super.setupFields() //Always! setTargetTable("SomeSequence"); setDescription("Some example Database Sequence"); this.setIncrement(new Integer(1)); // set the increment for the sequence this.setMinValue(new Integer(1)); // set the min value this.setMaxValue(new Integer(1000)); //set the max value (optional) this.setStart(new Integer(1)); //set the start value (optional)

Author:
Adam Rossi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject
DBObject.FieldError, DBObject.FieldUpdate
 
Field Summary
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_NAME, CACHE_TTY, DELETE, SEARCH, SYSTEM_ACCOUNT, SYSTEM_ACCOUNT_NAME, UPDATE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.DBObject
ATTRIBUTE_ERROR, ATTRIBUTE_ERROR_MESSAGE, ATTRIBUTE_PAGE_LIMIT, BIG_DECIMAL_ZERO, EMAIL_MASK, EVENT_ADD, EVENT_DELETE, EVENT_UPDATE, FLOAT_MASK, INT_MASK, IS_CHECK_RELATIONAL_INTEGRITY, UPDATE_CHANGED_ONLY, WHERE_KEYWORD
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, LONGBINARY_READ_DEFAULT_SIZE, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus, globalMask
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
DBSequence()
          DBSequence constructor comment.
DBSequence(DBConnection theConnection)
          Creation date: (4/7/00 2:45:10 PM)
DBSequence(int uid)
           
 
Method Summary
 void add()
          If the user is allowed to add, invoke the superclass add
 void clear()
          Set all fields to empty value & clear the last result set & clear sort keys and customWhereClause
 void createTable()
          Create the sequence in the database.
 void delete()
          Delete a record from the target table
 boolean find()
          Just like retrieve, but works with any fields, not just the key field.
 long getNext()
           
abstract  DBObject getThisDBObj()
          NOTE: Subclass must override.
 void retrieve()
          Get a particular record from the database into this object's fields Assumes that the key fields are set to the key of the object to be retrieved
 void search()
          Find a set of keys of all of the objects that match the current search critieria in the fields Assumes that the fields are populated with search criteria instead of data NOTE: Criteria in 'text' type colums is ignored (SQL Server limitation)
 Vector searchAndRetrieve()
           
 Vector searchAndRetrieve(String sortKeyString)
           
 void setIncrement(Integer I)
          Size of the increment step (defaults to 1 usually in most DB's).
 void setMaxValue(Integer I)
          Maximum value for the sequence.
 void setMinValue(Integer I)
          Minumum value for the sequence when created
 void setStart(Integer I)
          Where the sequence starts
protected  void setupFields()
          make sure that you override the setupFields() method and supply the proper setup parameters.
 void update()
          Not allowed...
 void verify()
          Does nothing...I am not sure what do to verify a sequence.
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, deleteAll, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.DBObject
addDetail, addField, addField, addFieldError, addFoundKeys, addIfNeeded, addIndex, addKey, addOrUpdate, addSortKey, addTransition, addVirtualField, addVirtualField, addVirtualField, addVirtualField, average, basicAdd, cacheIsChangedComparison, checkAllReferredToBy, checkAllRefs, checkAllRefsPublic, checkDeleteDetailPerm, checkField, checkRef, checkRef, clearDistinctFields, clearError, clearFieldsToRetrieve, clearSortKeys, containsWildCards, delete, deleteAll, deleteDetails, denotesRange, equals, forKey, formatDateTime, get, getAllAttributes, getAttribute, getAttributesIterator, getBooleanFieldValue, getCacheSize, getCacheStatsMap, getCacheUtil, getCheckZeroUpdate, getCustomWhereClause, getDataContext, getDataField, getDataTransferObject, getDBName, getDetails, getDistinctFieldCount, getDistinctFields, getField, getFieldBigDecimal, getFieldBoolean, getFieldByte, getFieldByteArray, getFieldData, getFieldDate, getFieldDecimalFormatted, getFieldDouble, getFieldErrorMessage, getFieldFloat, getFieldInt, getFieldLong, getFieldMetaData, getFieldShort, getFieldsToRetrieveCount, getFilterClass, getFoundCount, getFoundKeysArray, getIndexArray, getISOValuesDefault, getISOValuesDefault, getISOValuesDefault, getKey, getKeyFieldListIterator, getLength, getLengthInt, getLocalConnection, getLocale, getLogger, getLookupObject, getMax, getMax, getMaxRecords, getMyKeys, getMyUpdatesArray, getOffsetRecord, getPatternMatcher, getPrecision, getSerializedForm, getStringFilter, getThisDBbj, getValidValueDescrip, getValidValues, getValidValuesList, getValues, getValuesDefault, getValuesDefault, getValuesDefault, hasError, hasErrors, haveAllKeys, initialize, isCached, isChanged, isDistinct, isEmpty, isFieldDistinct, isFieldNull, isFieldsToRetrieve, isFieldToRetrieve, isMultiValued, isReadOnly, isSecret, isVirtual, loadFromConnection, logChange, max, min, newInstance, noNewLine, noQuotes, notifyListeners, populateDefaultValues, referredToBy, removeAttribute, removeFromCache, retrieveFromCache, saveBinaryField, search, set, setAttribute, setCacheSize, setCharset, setCheckZeroUpdate, setConnection, setConnection, setCustomWhereClause, setCustomWhereClause, setDataContext, setDataField, setDataTransferObject, setDefaultValue, setDescription, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldData, setFieldData, setFieldDistinct, setFieldsToRetrieve, setFilterClass, setFilterClass, setKeys, setLocale, setLookupField, setLookupObject, setMask, setMaxRecords, setMultiValued, setName, setOffsetRecord, setReadOnly, setSchema, setSecret, setSortKey, setStringFilter, setStringFiltersOnAll, setTargetDbSchema, setTargetTable, sqlAggrFunction, sum, toDebugString, update, updateAll, updateAll
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
addInParam, addOutParam, buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, createAndRunStoreProcedure, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, runStoredProcedure, runStoredProcedureAndRetrieveList, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setDBName, setMappedDataContext, setOriginalDBName, setTargetStoreProcedure
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getGlobalMask, getStatus, isGlobalMasked, setFieldsWithDefaults, setGlobalMask, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBSequence

public DBSequence()
           throws DBException
DBSequence constructor comment.

Throws:
DBException - The exception description.

DBSequence

public DBSequence(DBConnection theConnection)
           throws DBException
Creation date: (4/7/00 2:45:10 PM)

Parameters:
theConnection - com.jcorporate.expresso.core.db.DBConnection

DBSequence

public DBSequence(int uid)
           throws DBException
Method Detail

add

public void add()
         throws DBException
Description copied from class: SecuredDBObject
If the user is allowed to add, invoke the superclass add

Specified by:
add in interface DataObject
Overrides:
add in class SecuredDBObject
Throws:
DBException

clear

public void clear()
           throws DBException
Description copied from class: DBObject
Set all fields to empty value & clear the last result set & clear sort keys and customWhereClause

Specified by:
clear in interface DataObject
Overrides:
clear in class DBObject
Throws:
DBException - The exception description.

createTable

public void createTable()
                 throws DBException
Create the sequence in the database. Assumes it is not there already.

Throws:
DBException

delete

public void delete()
            throws DBException
Description copied from class: SecuredDBObject
Delete a record from the target table

Specified by:
delete in interface DataObject
Overrides:
delete in class SecuredDBObject
Throws:
DBException - The exception description.

find

public boolean find()
             throws DBException
Description copied from class: SecuredDBObject
Just like retrieve, but works with any fields, not just the key field. Finds only first record matching the criteria

Specified by:
find in interface DataObject
Overrides:
find in class SecuredDBObject
Returns:
boolean
Throws:
DBException - The exception description.

getNext

public long getNext()
             throws DBException
Returns:
long
Throws:
DBException

getThisDBObj

public abstract DBObject getThisDBObj()
                               throws DBException
NOTE: Subclass must override. This method should return a new object of the type of the subclass

Overrides:
getThisDBObj in class DBObject
Returns:
DBObject A newly allocated object of the subclass's class
Throws:
DBException - upon error.
See Also:
DBObject.getThisDBObj()

retrieve

public void retrieve()
              throws DBException
Description copied from class: SecuredDBObject
Get a particular record from the database into this object's fields Assumes that the key fields are set to the key of the object to be retrieved

Overrides:
retrieve in class SecuredDBObject
Throws:
DBException - The exception description.

search

public void search()
            throws DBException
Description copied from class: SecuredDBObject
Find a set of keys of all of the objects that match the current search critieria in the fields Assumes that the fields are populated with search criteria instead of data NOTE: Criteria in 'text' type colums is ignored (SQL Server limitation)

Overrides:
search in class SecuredDBObject
Throws:
DBException - The exception description.

searchAndRetrieve

public Vector searchAndRetrieve()
                         throws DBException
Returns:
java.util.Vector
Throws:
DBException - The exception description.

searchAndRetrieve

public Vector searchAndRetrieve(String sortKeyString)
                         throws DBException
Parameters:
sortKeyString - java.lang.String
Returns:
java.util.Vector
Throws:
DBException - The exception description.

setIncrement

public void setIncrement(Integer I)
Size of the increment step (defaults to 1 usually in most DB's).

Parameters:
I - java.lang.Integer

setMaxValue

public void setMaxValue(Integer I)
Maximum value for the sequence.

Parameters:
I - java.lang.Integer

setMinValue

public void setMinValue(Integer I)
Minumum value for the sequence when created

Parameters:
I - java.lang.Integer

setStart

public void setStart(Integer I)
Where the sequence starts

Parameters:
I - java.lang.Integer

setupFields

protected void setupFields()
                    throws DBException
make sure that you override the setupFields() method and supply the proper setup parameters.

ex:

super.setupFields() //Always! setTargetTable("SomeSequence"); setDescription("Some example Database Sequence"); this.setIncrement(new Integer(1)); // set the increment for the sequence this.setMinValue(new Integer(1)); // set the min value this.setMaxValue(new Integer(1000)); //set the max value (optional) this.setStart(new Integer(1)); //set the start value (optional)

Overrides:
setupFields in class DBObject
Throws:
DBException - If there is an error setting up the fields as requested. For example, if a field allowing null is requested as part of the key

update

public void update()
            throws DBException
Not allowed...

Specified by:
update in interface DataObject
Overrides:
update in class SecuredDBObject
Throws:
DBException - The exception description.

verify

public void verify()
            throws DBException
Does nothing...I am not sure what do to verify a sequence.

Overrides:
verify in class DBObject
Throws:
DBException - If the validation fails

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.