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
FieldsFields inherited from class org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
current, typeFields inherited from interface org.apache.openjpa.kernel.Seq
TYPE_CONTIGUOUS, TYPE_DEFAULT, TYPE_NONTRANSACTIONAL, TYPE_TRANSACTIONAL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSchema(ClassMapping mapping, SchemaGroup group) No-op.protected voidallocateInternal(int additional, JDBCStore store, ClassMapping mapping) Allocate additional sequence values.voidDrops the sequence in the DB.voidInvoked upon completion of bean property configuration for this object.intReturn theJDBCConfigurationfor this sequence.intintDeprecated.The sequence name.static voidUsage: java org.apache.openjpa.jdbc.schema.NativeJDBCSequence [option]* -action/-a <add | drop | get> Where the following options are recognized.protected ObjectnextInternal(JDBCStore store, ClassMapping mapping) Return the next sequence object.voidCreates the sequence in the DB.static booleanrun(JDBCConfiguration conf, String[] args, String action) Run the tool.static booleanrun(JDBCConfiguration conf, String[] args, Options opts) Run the tool.voidsetAllocate(int allocate) voidInvoked prior to setting bean properties.voidsetIncrement(int increment) voidsetInitialValue(int initial) voidDeprecated.voidsetSequence(String seqName) The sequence name.voidInvoked 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:AbstractJDBCSeqNo-op.- Specified by:
addSchemain interfaceJDBCSeq- Overrides:
addSchemain classAbstractJDBCSeq
-
getConfiguration
Description copied from class:AbstractJDBCSeqReturn theJDBCConfigurationfor this sequence.- Specified by:
getConfigurationin classAbstractJDBCSeq
-
setConfiguration
Description copied from interface:ConfigurableInvoked prior to setting bean properties.- Specified by:
setConfigurationin interfaceConfigurable
-
startConfiguration
public void startConfiguration()Description copied from interface:ConfigurableInvoked before bean property configuration is begun on this object.- Specified by:
startConfigurationin interfaceConfigurable
-
endConfiguration
public void endConfiguration()Description copied from interface:ConfigurableInvoked upon completion of bean property configuration for this object.- Specified by:
endConfigurationin interfaceConfigurable
-
nextInternal
Description copied from class:AbstractJDBCSeqReturn the next sequence object.- Specified by:
nextInternalin classAbstractJDBCSeq- Throws:
SQLException
-
allocateInternal
protected void allocateInternal(int additional, JDBCStore store, ClassMapping mapping) throws SQLException Allocate additional sequence values.- Overrides:
allocateInternalin 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
JDBCConfigurationcan 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
-