|
SolarMetric Kodo JDO 3.2.4 generated on January 7 2005 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kodo.jdbc.schema.ClassSequenceFactory
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.
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 |
public static final String SEQUENCE_EXT
jdbc-sequence-name
Constructor Detail |
public ClassSequenceFactory()
Method Detail |
public String getTableName()
public void setTableName(String name)
DUAL
.name
- the name of the tablepublic String getFormat()
MessageFormat
string to use as for SQL generation.public void setFormat(String messageFormat)
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).public String getSequenceName()
public void setSequenceName(String seqName)
JDOSEQUENCE
.public void addSchema(ClassMapping mapping, SchemaGroup group)
SequenceFactory
addSchema
in interface SequenceFactory
public long getNext(ClassMapping mapping, DataSource ds) throws SQLException
SequenceFactory
getNext
in interface SequenceFactory
kodo.jdbc.schema.SequenceFactory
mapping
- metadata on the class of the object being persistedds
- the data source from which to obtain database
connections, if any are neededpublic boolean ensureCapacity(int count, ClassMapping cm, DataSource ds)
SequenceFactory
count
new sequence
values.ensureCapacity
in interface SequenceFactory
kodo.jdbc.schema.SequenceFactory
count
- number of sequence values to attempt to servecm
- metadata on the class of the object being persistedds
- the data source from which to obtain database
connections, if any are neededtrue
if the factory can service
count
requests without returning to the
datastore; else false
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.
Configuration
;
optionalJDBCConfiguration
can be set by using their
names and supplying a value; for example:
-licenseKey adslfja83r3lkadf
public static boolean run(JDBCConfiguration conf, String[] args, serp.util.Options opts) throws SQLException
main(java.lang.String[])
public static void run(JDBCConfiguration conf, String[] args, MappingRepository repos, ClassLoader loader) throws SQLException
|
SolarMetric Kodo JDO 3.2.4 generated on January 7 2005 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |