SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

kodo.jdbc.schema
Class DBSequenceFactory

java.lang.Object
  |
  +--kodo.jdbc.schema.DBSequenceFactory
All Implemented Interfaces:
Configurable, SequenceFactory
Direct Known Subclasses:
ClassDBSequenceFactory

public class DBSequenceFactory
extends Object
implements SequenceFactory, Configurable

SequenceFactory implementation that uses a database table for sequence number generation. The table is automatically created if not already present.


Inner Class Summary
protected static class DBSequenceFactory.Seq
          Helper struct to hold sequence information.
 
Field Summary
static String ACTION_ADD
           
static String ACTION_DROP
           
static String ACTION_INCREMENT
           
 
Constructor Summary
DBSequenceFactory()
           
 
Method Summary
protected  Column addPrimaryKeyColumn(Table table)
          Add the primary key column to the given table and return it.
 void addSchema(ClassMapping mapping, SchemaGroup group)
          Add any tables, etc needed by this factory for the given mapping to the given schema group, if they do not exist already.
 void dropTable()
          Drops the sequence table in the DB.
 void endConfiguration()
          Invoked upon completion of bean property configuration for this object.
 boolean ensureCapacity(int count, ClassMapping cm, DataSource ds)
          Ensures that this sequence factory has sufficient capacity readily available to provide count new sequence values.
 JDBCConfiguration getConfiguration()
           
protected  Connection getConnection(DataSource ds)
          Return a connection to use.
 int getIncrement()
          Return the increment to us when updating the sequence table.
 long getNext(ClassMapping mapping, DataSource ds)
          Return a unique primary key value.
protected  void getNext(ClassMapping mapping, DBSequenceFactory.Seq seq, DataSource ds, int inc)
           
protected  Object getPrimaryKey(ClassMapping mapping)
          Return the primary key value for the given mapping.
 String getPrimaryKeyColumn()
          The name of the table's primary key column.
protected  DBSequenceFactory.Seq getSeq(ClassMapping mapping)
          Return the appropriate sequence info object for the given mapping.
 String getSequenceColumn()
          The name of the column that holds the sequence value.
 String getTableName()
          The sequence table name.
static void main(String[] args)
          Usage: java kodo.jdbc.schema.DBSequenceFactory [option]* -action/-a <add | drop | increment>
 void refreshTable()
          Creates the sequence table in the DB.
static boolean run(JDBCConfiguration conf, String[] args, serp.util.Options opts)
          Run the tool.
static boolean run(JDBCConfiguration conf, String action, Writer out)
          Run the tool.
 void setConfiguration(Configuration conf)
          Invoked prior to setting bean properties.
 void setIncrement(int inc)
          Set the increment to use when updating the sequence table.
 void setPrimaryKeyColumn(String primaryKeyColumn)
          The name of the table's primary key column.
 void setSequenceColumn(String sequenceColumn)
          The name of the column that holds the sequence value.
 void setTableName(String name)
          The sequence table name.
 void startConfiguration()
          Invoked before bean property configuration is begun on this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_DROP

public static final String ACTION_DROP

ACTION_ADD

public static final String ACTION_ADD

ACTION_INCREMENT

public static final String ACTION_INCREMENT
Constructor Detail

DBSequenceFactory

public DBSequenceFactory()
Method Detail

getTableName

public String getTableName()
The sequence table name. Defaults to JDO_SEQUENCE. By default, the table will be placed in the first schema listed in your kodo.jdbc.Schemas property, or in the default schema if the property is not given. If you specify a table name in the form <schema>.<table>, then the given schema will be used.

setTableName

public void setTableName(String name)
The sequence table name. Defaults to JDO_SEQUENCE. By default, the table will be placed in the first schema listed in your kodo.jdbc.Schemas property, or in the default schema if the property is not given. If you specify a table name in the form <schema>.<table>, then the given schema will be used.

getSequenceColumn

public String getSequenceColumn()
The name of the column that holds the sequence value. Defaults to SEQUENCE_VALUE.

setSequenceColumn

public void setSequenceColumn(String sequenceColumn)
The name of the column that holds the sequence value. Defaults to SEQUENCE_VALUE.

getPrimaryKeyColumn

public String getPrimaryKeyColumn()
The name of the table's primary key column. Defaults to ID.

setPrimaryKeyColumn

public void setPrimaryKeyColumn(String primaryKeyColumn)
The name of the table's primary key column. Defaults to ID.

getIncrement

public int getIncrement()
Return the increment to us when updating the sequence table. Sequence numbers will be grabbed in blocks of this value to reduce the number of transactions that must be performed on the sequence table.

setIncrement

public void setIncrement(int inc)
Set the increment to use when updating the sequence table. Defaults to 50, meaning a transaction has to take place on the sequence table only every 50 new objects created.

getConfiguration

public JDBCConfiguration getConfiguration()

setConfiguration

public void setConfiguration(Configuration conf)
Description copied from interface: Configurable
Invoked prior to setting bean properties.
Specified by:
setConfiguration in interface Configurable

startConfiguration

public void startConfiguration()
Description copied from interface: Configurable
Invoked before bean property configuration is begun on this object.
Specified by:
startConfiguration in interface Configurable

endConfiguration

public void endConfiguration()
Description copied from interface: Configurable
Invoked upon completion of bean property configuration for this object.
Specified by:
endConfiguration in interface Configurable

addSchema

public void addSchema(ClassMapping mapping,
                      SchemaGroup group)
Description copied from interface: SequenceFactory
Add any tables, etc needed by this factory for the given mapping to the given schema group, if they do not exist already.
Specified by:
addSchema in interface SequenceFactory

getNext

public long getNext(ClassMapping mapping,
                    DataSource ds)
             throws Exception
Description copied from interface: SequenceFactory
Return a unique primary key value.
Specified by:
getNext in interface SequenceFactory
Following copied from interface: kodo.jdbc.schema.SequenceFactory
Parameters:
mapping - metadata on the class of the object being persisted
ds - the data source from which to obtain database connections, if any are needed

getNext

protected void getNext(ClassMapping mapping,
                       DBSequenceFactory.Seq seq,
                       DataSource ds,
                       int inc)

ensureCapacity

public boolean ensureCapacity(int count,
                              ClassMapping cm,
                              DataSource ds)
Description copied from interface: SequenceFactory
Ensures that this sequence factory has sufficient capacity readily available to provide count new sequence values.
Specified by:
ensureCapacity in interface SequenceFactory
Following copied from interface: kodo.jdbc.schema.SequenceFactory
Parameters:
count - number of sequence values to attempt to serve
cm - metadata on the class of the object being persisted
ds - the data source from which to obtain database connections, if any are needed
Returns:
true if the factory can service count requests without returning to the datastore; else false

getSeq

protected DBSequenceFactory.Seq getSeq(ClassMapping mapping)
Return the appropriate sequence info object for the given mapping.

addPrimaryKeyColumn

protected Column addPrimaryKeyColumn(Table table)
Add the primary key column to the given table and return it.

getPrimaryKey

protected Object getPrimaryKey(ClassMapping mapping)
Return the primary key value for the given mapping.

getConnection

protected Connection getConnection(DataSource ds)
                            throws SQLException
Return a connection to use.

refreshTable

public void refreshTable()
                  throws SQLException
Creates the sequence table in the DB.

dropTable

public void dropTable()
               throws SQLException
Drops the sequence table in the DB.

main

public static void main(String[] args)
                 throws Exception

Usage: java kodo.jdbc.schema.DBSequenceFactory [option]* -action/-a <add | drop | increment>

Where the following options are recognized.

The various actions are as follows.


run

public static boolean run(JDBCConfiguration conf,
                          String[] args,
                          serp.util.Options opts)
                   throws Exception
Run the tool. Returns false if invalid options were given.

run

public static boolean run(JDBCConfiguration conf,
                          String action,
                          Writer out)
                   throws Exception
Run the tool. Return false if an invalid option was given.

SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.