com.objectwave.persist.broker
Class TableSequence

java.lang.Object
  |
  +--com.objectwave.persist.broker.TableSequence
All Implemented Interfaces:
PrimaryKeyStrategy

public class TableSequence
extends java.lang.Object
implements PrimaryKeyStrategy

This PrimaryKeyStrategy involves selecting a sequence value from a table. The column name selected is constructed with the following format {0}_uid_seq, where {0} is the table name of the persistent object that requires a PK.

Version:
$Id: TableSequence.java,v 2.1 2001/10/03 14:59:03 dave_hoag Exp $
Author:
Trever M. Shick with help from dhoag

Field Summary
protected  java.lang.String sequenceColumnSuffix
           
protected  java.lang.String sequenceTableName
           
 
Constructor Summary
TableSequence()
           
 
Method Summary
 java.lang.String getSequenceColumnSuffix()
          Returns the suffix of the column which is queried to get the next sequence number for a given table.
 java.lang.String getSequenceTableName()
          Returns the name of the table which is queried to get the next sequence number for a given table.
 java.lang.Object nextPrimaryKey(RDBBroker broker, RDBPersistence pObj)
          Calls to this method should never return the same value.
 void setSequenceColumnSuffix(java.lang.String newSuffix)
          Bean style mutator to allow client code to alter which column that the sequence value is selected from.
 void setSequenceTableName(java.lang.String newTableName)
          Bean style mutator to allow client code to alter which table that the sequence value is selected from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequenceTableName

protected java.lang.String sequenceTableName

sequenceColumnSuffix

protected java.lang.String sequenceColumnSuffix
Constructor Detail

TableSequence

public TableSequence()
Method Detail

setSequenceTableName

public void setSequenceTableName(java.lang.String newTableName)
Bean style mutator to allow client code to alter which table that the sequence value is selected from. If newTableName is null or a 0 length string, the parameter is ignored and the value is not changed.

Parameters:
newTableName - The new table name from which to select the sequence value from.

setSequenceColumnSuffix

public void setSequenceColumnSuffix(java.lang.String newSuffix)
Bean style mutator to allow client code to alter which column that the sequence value is selected from. If newColumnName is null or a 0 length string, the parameter is ignored and the value is not changed.

Parameters:
newSuffix - The new SequenceColumnSuffix value

getSequenceTableName

public java.lang.String getSequenceTableName()
Returns the name of the table which is queried to get the next sequence number for a given table. With Oracle, this is generally "DUAL" since sequence values are often accessed via performing : SELECT my_seq.nextval FROM DUAL;

Returns:
The name of the table from which a sequence value is selected.

getSequenceColumnSuffix

public java.lang.String getSequenceColumnSuffix()
Returns the suffix of the column which is queried to get the next sequence number for a given table. With Oracle, this is generally "_uid_seq.NEXTVAL" since sequence values are often accessed via performing : SELECT my_uid_seq.nextval FROM DUAL; "my" is the table name of the persistent object for which a sequence is being gathered.

Returns:
The name of the table from which a sequence value is selected.

nextPrimaryKey

public java.lang.Object nextPrimaryKey(RDBBroker broker,
                                       RDBPersistence pObj)
                                throws java.sql.SQLException,
                                       QueryException
Description copied from interface: PrimaryKeyStrategy
Calls to this method should never return the same value. When this method is called, the broker assumes the value returned will create a unique primary key value that can identify a unique row in the database.

Specified by:
nextPrimaryKey in interface PrimaryKeyStrategy
Parameters:
broker - - The current broker being used.
pObj - - The peristent object to get a primary key for
Returns:
an object that represents the next primary key value for the given persistent object pObj
Throws:
java.sql.SQLException
QueryException