Package org.apache.openjpa.jdbc.kernel
Class NativeJDBCSeq
- java.lang.Object
-
- org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
-
- org.apache.openjpa.jdbc.kernel.NativeJDBCSeq
-
- All Implemented Interfaces:
JDBCSeq
,Seq
,Configurable
,Closeable
public class NativeJDBCSeq extends AbstractJDBCSeq implements Configurable
JDBCSeq
implementation that uses a database sequence to generate numbers. Supports allocation (caching). In order for allocation to work properly, the database sequence must be defined with INCREMENT BY value equal to allocate * increment.- See Also:
JDBCSeq
,AbstractJDBCSeq
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACTION_ADD
static java.lang.String
ACTION_DROP
static java.lang.String
ACTION_GET
-
Fields inherited from class org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
current, type
-
Fields inherited from interface org.apache.openjpa.kernel.Seq
TYPE_CONTIGUOUS, TYPE_DEFAULT, TYPE_NONTRANSACTIONAL, TYPE_TRANSACTIONAL
-
-
Constructor Summary
Constructors Constructor Description NativeJDBCSeq()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addSchema(ClassMapping mapping, SchemaGroup group)
No-op.protected void
allocateInternal(int additional, JDBCStore store, ClassMapping mapping)
Allocate additional sequence values.void
dropSequence()
Drops the sequence in the DB.void
endConfiguration()
Invoked upon completion of bean property configuration for this object.int
getAllocate()
JDBCConfiguration
getConfiguration()
Return theJDBCConfiguration
for this sequence.int
getIncrement()
int
getInitialValue()
java.lang.String
getSchema()
Deprecated.DBIdentifier
getSchemaIdentifier()
java.lang.String
getSequence()
The sequence name.static void
main(java.lang.String[] args)
Usage: java org.apache.openjpa.jdbc.schema.NativeJDBCSequence [option]* -action/-a <add | drop | get> Where the following options are recognized.protected java.lang.Object
nextInternal(JDBCStore store, ClassMapping mapping)
Return the next sequence object.void
refreshSequence()
Creates the sequence in the DB.static boolean
run(JDBCConfiguration conf, java.lang.String[] args, java.lang.String action)
Run the tool.static boolean
run(JDBCConfiguration conf, java.lang.String[] args, Options opts)
Run the tool.void
setAllocate(int allocate)
void
setConfiguration(Configuration conf)
Invoked prior to setting bean properties.void
setIncrement(int increment)
void
setInitialValue(int initial)
void
setSchema(java.lang.String schema)
Deprecated.void
setSequence(java.lang.String seqName)
The sequence name.void
startConfiguration()
Invoked before bean property configuration is begun on this object.-
Methods inherited from class org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
allocate, close, closeConnection, current, currentInternal, getConnection, getConnection, next, setType, suspendInJTA
-
-
-
-
Field Detail
-
ACTION_DROP
public static final java.lang.String ACTION_DROP
- See Also:
- Constant Field Values
-
ACTION_ADD
public static final java.lang.String ACTION_ADD
- See Also:
- Constant Field Values
-
ACTION_GET
public static final java.lang.String ACTION_GET
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSequence
public java.lang.String getSequence()
The sequence name. Defaults toOPENJPA_SEQUENCE
.
-
setSequence
public void setSequence(java.lang.String seqName)
The sequence name. Defaults toOPENJPA_SEQUENCE
.
-
getInitialValue
public int getInitialValue()
- See Also:
Sequence.getInitialValue()
-
setInitialValue
public void setInitialValue(int initial)
- See Also:
Sequence.setInitialValue(int)
-
getAllocate
public int getAllocate()
- See Also:
Sequence.getAllocate()
-
setAllocate
public void setAllocate(int allocate)
- See Also:
Sequence.setAllocate(int)
-
getIncrement
public int getIncrement()
- See Also:
Sequence.getIncrement()
-
setIncrement
public void setIncrement(int increment)
- See Also:
Sequence.setIncrement(int)
-
addSchema
public void addSchema(ClassMapping mapping, SchemaGroup group)
Description copied from class:AbstractJDBCSeq
No-op.- Specified by:
addSchema
in interfaceJDBCSeq
- Overrides:
addSchema
in classAbstractJDBCSeq
-
getConfiguration
public JDBCConfiguration getConfiguration()
Description copied from class:AbstractJDBCSeq
Return theJDBCConfiguration
for this sequence.- Specified by:
getConfiguration
in classAbstractJDBCSeq
-
setConfiguration
public void setConfiguration(Configuration conf)
Description copied from interface:Configurable
Invoked prior to setting bean properties.- Specified by:
setConfiguration
in interfaceConfigurable
-
startConfiguration
public void startConfiguration()
Description copied from interface:Configurable
Invoked before bean property configuration is begun on this object.- Specified by:
startConfiguration
in interfaceConfigurable
-
endConfiguration
public void endConfiguration()
Description copied from interface:Configurable
Invoked upon completion of bean property configuration for this object.- Specified by:
endConfiguration
in interfaceConfigurable
-
nextInternal
protected java.lang.Object nextInternal(JDBCStore store, ClassMapping mapping) throws java.sql.SQLException
Description copied from class:AbstractJDBCSeq
Return the next sequence object.- Specified by:
nextInternal
in classAbstractJDBCSeq
- Throws:
java.sql.SQLException
-
allocateInternal
protected void allocateInternal(int additional, JDBCStore store, ClassMapping mapping) throws java.sql.SQLException
Allocate additional sequence values.- Overrides:
allocateInternal
in classAbstractJDBCSeq
- Parameters:
additional
- ignored - the allocation size is fixed and determined by allocate and increment properties.store
- used to obtain connectionmapping
- ignored- Throws:
java.sql.SQLException
-
refreshSequence
public void refreshSequence() throws java.sql.SQLException
Creates the sequence in the DB.- Throws:
java.sql.SQLException
-
dropSequence
public void dropSequence() throws java.sql.SQLException
Drops the sequence in the DB.- Throws:
java.sql.SQLException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Usage: java org.apache.openjpa.jdbc.schema.NativeJDBCSequence [option]* -action/-a <add | drop | get> Where the following options are recognized.- -properties/-p <properties file or resource>: The
path or resource name of an OpenJPA properties file containing
information such as connection data as
outlined in
JDBCConfiguration
. Optional. - -<property name> <property value>: All bean
properties of the OpenJPA
JDBCConfiguration
can be set by using their names and supplying a value.
- add: Create the sequence.
- drop: Drop the sequence.
- get: Print the next sequence value.
- Throws:
java.lang.Exception
- -properties/-p <properties file or resource>: The
path or resource name of an OpenJPA properties file containing
information such as connection data as
outlined in
-
run
public static boolean run(JDBCConfiguration conf, java.lang.String[] args, Options opts) throws java.lang.Exception
Run the tool. Returns false if invalid options were given.- Throws:
java.lang.Exception
-
run
public static boolean run(JDBCConfiguration conf, java.lang.String[] args, java.lang.String action) throws java.lang.Exception
Run the tool. Returns false if an invalid option was given.- Throws:
java.lang.Exception
-
setSchema
@Deprecated public void setSchema(java.lang.String schema)
Deprecated.
-
getSchema
@Deprecated public java.lang.String getSchema()
Deprecated.
-
getSchemaIdentifier
public DBIdentifier getSchemaIdentifier()
-
-