SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

kodo.jdbc.schema
Class ClassSequenceFactory

java.lang.Object
  |
  +--kodo.jdbc.schema.ClassSequenceFactory
All Implemented Interfaces:
SequenceFactory

public class ClassSequenceFactory
extends Object
implements SequenceFactory

SequenceFactory implementation that uses a database sequences to generate numbers. The factory can be configured with a default sequence name to use, but also looks for a jdbc-sequence metadata extension, which can be used to override the default for an individual class.

This code was designed as an example to plugin developrs. It has only been tested with Oracle. Other databases may require changes.

See Also:
SequenceFactory

Field Summary
static String SEQUENCE_EXT
          The the class metadata extension that stores the sequence name to use for the class: jdbc-sequence-name
 
Constructor Summary
ClassSequenceFactory()
           
 
Method Summary
 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.
 boolean ensureCapacity(int count, ClassMapping cm, DataSource ds)
          Ensures that this sequence factory has sufficient capacity readily available to provide count new sequence values.
 String getFormat()
          Return the MessageFormat string to use as for SQL generation.
 long getNext(ClassMapping mapping, DataSource ds)
          Return a unique primary key value.
 String getSequenceName()
          Return the name of the default sequence for classes that do not list one in their metadata.
 String getTableName()
          Return the table name to run sequence queries against.
static void main(String[] args)
          Usage: java kodo.jdbc.schema.ClassSequenceFactory [option]* [class name | .java file | .class file | .jdo file]*
static void run(JDBCConfiguration conf, String[] args, MappingRepository repos, ClassLoader loader)
          Run the tool.
static boolean run(JDBCConfiguration conf, String[] args, serp.util.Options opts)
          Run the tool.
 void setFormat(String messageFormat)
          Set the string used for MessageFormat to generate the sequence selecting SQL.
 void setSequenceName(String seqName)
          Set the default sequence used.
 void setTableName(String name)
          Set the table name to run sequence queries against.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEQUENCE_EXT

public static final String SEQUENCE_EXT
The the class metadata extension that stores the sequence name to use for the class: jdbc-sequence-name
Constructor Detail

ClassSequenceFactory

public ClassSequenceFactory()
Method Detail

getTableName

public String getTableName()
Return the table name to run sequence queries against.

setTableName

public void setTableName(String name)
Set the table name to run sequence queries against. Defaults to DUAL.
Parameters:
name - the name of the table

getFormat

public String getFormat()
Return the MessageFormat string to use as for SQL generation.

setFormat

public void setFormat(String messageFormat)
Set the string used for MessageFormat to generate the sequence selecting SQL. Should have two placeholders: {0} for the sequence name and {1} for the table name (e.g. dual).

getSequenceName

public String getSequenceName()
Return the name of the default sequence for classes that do not list one in their metadata.

setSequenceName

public void setSequenceName(String seqName)
Set the default sequence used. Defaults to JDOSEQUENCE.

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 SQLException
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

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

main

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

Usage: java kodo.jdbc.schema.ClassSequenceFactory [option]* [class name | .java file | .class file | .jdo file]*

Where the following options are recognized.


run

public static boolean run(JDBCConfiguration conf,
                          String[] args,
                          serp.util.Options opts)
                   throws SQLException
Run the tool. Returns false if invalid options were given.
See Also:
main(java.lang.String[])

run

public static void run(JDBCConfiguration conf,
                       String[] args,
                       MappingRepository repos,
                       ClassLoader loader)
                throws SQLException
Run the tool.

SolarMetric Kodo JDO 3.2.4 generated on January 7 2005

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