org.openware.job.ejb
Class SimpleKeyGen
java.lang.Object
|
+--org.openware.job.ejb.KeyGen
|
+--org.openware.job.ejb.SimpleKeyGen
- public class SimpleKeyGen
- extends KeyGen
A simple primary key generator that uses an algorithm that is
basically a Hi/Lo algorithm. Basically, it reads a key value from
the database, adds 1000 to it and writes it back to the database.
After this, the next 1000 keys are derived without accessing the
database. This algorithm should also allow another tool to use
the same table for primary key generation.
Requires the following script (converted to your particular database)
be added to your database:
CREATE TABLE job_SequenceTable (
primKey INT8,
nextId INT8
);
INSERT INTO SequenceTable (primKey, nextId) VALUES (1, 1);
JOB will do this for you normally.
- Version:
- $Revision: 1.6 $ $Date: 2001/07/12 20:19:14 $
- Author:
- Vincent Sheffer
Method Summary |
long |
nextKey(java.sql.Connection conn,
long numToGet)
Get the next key in the sequence. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleKeyGen
public SimpleKeyGen()
nextKey
public long nextKey(java.sql.Connection conn,
long numToGet)
throws java.sql.SQLException
- Get the next key in the sequence.
NOTE: This method should be called from
inside a transaction.
- Overrides:
nextKey
in class KeyGen
- Parameters:
conn
- The database connection to use when the value must
come from the database table.
Copyright © 2000,2001 Openware. All Rights Reserved.