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
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:
-
Field Summary
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSchema
(ClassMapping mapping, SchemaGroup group) No-op.protected void
allocateInternal
(int additional, JDBCStore store, ClassMapping mapping) Allocate additional sequence values.void
Drops the sequence in the DB.void
Invoked upon completion of bean property configuration for this object.int
Return theJDBCConfiguration
for this sequence.int
int
Deprecated.The sequence name.static void
Usage: java org.apache.openjpa.jdbc.schema.NativeJDBCSequence [option]* -action/-a <add | drop | get> Where the following options are recognized.protected Object
nextInternal
(JDBCStore store, ClassMapping mapping) Return the next sequence object.void
Creates the sequence in the DB.static boolean
run
(JDBCConfiguration conf, String[] args, String action) Run the tool.static boolean
run
(JDBCConfiguration conf, String[] args, Options opts) Run the tool.void
setAllocate
(int allocate) void
Invoked prior to setting bean properties.void
setIncrement
(int increment) void
setInitialValue
(int initial) void
Deprecated.void
setSequence
(String seqName) The sequence name.void
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 Details
-
ACTION_DROP
- See Also:
-
ACTION_ADD
- See Also:
-
ACTION_GET
- See Also:
-
-
Constructor Details
-
NativeJDBCSeq
public NativeJDBCSeq()
-
-
Method Details
-
getSequence
The sequence name. Defaults toOPENJPA_SEQUENCE
. -
setSequence
The sequence name. Defaults toOPENJPA_SEQUENCE
. -
getInitialValue
public int getInitialValue()- See Also:
-
setInitialValue
public void setInitialValue(int initial) - See Also:
-
getAllocate
public int getAllocate()- See Also:
-
setAllocate
public void setAllocate(int allocate) - See Also:
-
getIncrement
public int getIncrement()- See Also:
-
setIncrement
public void setIncrement(int increment) - See Also:
-
addSchema
Description copied from class:AbstractJDBCSeq
No-op.- Specified by:
addSchema
in interfaceJDBCSeq
- Overrides:
addSchema
in classAbstractJDBCSeq
-
getConfiguration
Description copied from class:AbstractJDBCSeq
Return theJDBCConfiguration
for this sequence.- Specified by:
getConfiguration
in classAbstractJDBCSeq
-
setConfiguration
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
Description copied from class:AbstractJDBCSeq
Return the next sequence object.- Specified by:
nextInternal
in classAbstractJDBCSeq
- Throws:
SQLException
-
allocateInternal
protected void allocateInternal(int additional, JDBCStore store, ClassMapping mapping) throws 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:
SQLException
-
refreshSequence
Creates the sequence in the DB.- Throws:
SQLException
-
dropSequence
Drops the sequence in the DB.- Throws:
SQLException
-
main
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:
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
Run the tool. Returns false if invalid options were given.- Throws:
Exception
-
run
Run the tool. Returns false if an invalid option was given.- Throws:
Exception
-
setSchema
Deprecated. -
getSchema
Deprecated. -
getSchemaIdentifier
-