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
JDBCSeqimplementation 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 StringACTION_ADDstatic StringACTION_DROPstatic StringACTION_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 voidaddSchema(ClassMapping mapping, SchemaGroup group)No-op.protected voidallocateInternal(int additional, JDBCStore store, ClassMapping mapping)Allocate additional sequence values.voiddropSequence()Drops the sequence in the DB.voidendConfiguration()Invoked upon completion of bean property configuration for this object.intgetAllocate()JDBCConfigurationgetConfiguration()Return theJDBCConfigurationfor this sequence.intgetIncrement()intgetInitialValue()StringgetSchema()Deprecated.DBIdentifiergetSchemaIdentifier()StringgetSequence()The sequence name.static voidmain(String[] args)Usage: 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.voidrefreshSequence()Creates 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)voidsetConfiguration(Configuration conf)Invoked prior to setting bean properties.voidsetIncrement(int increment)voidsetInitialValue(int initial)voidsetSchema(String schema)Deprecated.voidsetSequence(String seqName)The sequence name.voidstartConfiguration()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 String ACTION_DROP
- See Also:
- Constant Field Values
-
ACTION_ADD
public static final String ACTION_ADD
- See Also:
- Constant Field Values
-
ACTION_GET
public static final String ACTION_GET
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSequence
public String getSequence()
The sequence name. Defaults toOPENJPA_SEQUENCE.
-
setSequence
public void setSequence(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:AbstractJDBCSeqNo-op.- Specified by:
addSchemain interfaceJDBCSeq- Overrides:
addSchemain classAbstractJDBCSeq
-
getConfiguration
public JDBCConfiguration getConfiguration()
Description copied from class:AbstractJDBCSeqReturn theJDBCConfigurationfor this sequence.- Specified by:
getConfigurationin classAbstractJDBCSeq
-
setConfiguration
public void setConfiguration(Configuration conf)
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
protected Object nextInternal(JDBCStore store, ClassMapping mapping) throws SQLException
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 SQLExceptionAllocate 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
public void refreshSequence() throws SQLExceptionCreates the sequence in the DB.- Throws:
SQLException
-
dropSequence
public void dropSequence() throws SQLExceptionDrops the sequence in the DB.- Throws:
SQLException
-
main
public static void main(String[] args) throws 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
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
public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws Exception
Run the tool. Returns false if invalid options were given.- Throws:
Exception
-
run
public static boolean run(JDBCConfiguration conf, String[] args, String action) throws Exception
Run the tool. Returns false if an invalid option was given.- Throws:
Exception
-
setSchema
@Deprecated public void setSchema(String schema)
Deprecated.
-
getSchema
@Deprecated public String getSchema()
Deprecated.
-
getSchemaIdentifier
public DBIdentifier getSchemaIdentifier()
-
-