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 java.lang.StringACTION_ADDstatic java.lang.StringACTION_DROPstatic java.lang.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()java.lang.StringgetSchema()Deprecated.DBIdentifiergetSchemaIdentifier()java.lang.StringgetSequence()The sequence name.static voidmain(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.ObjectnextInternal(JDBCStore store, ClassMapping mapping)Return the next sequence object.voidrefreshSequence()Creates the sequence in the DB.static booleanrun(JDBCConfiguration conf, java.lang.String[] args, java.lang.String action)Run the tool.static booleanrun(JDBCConfiguration conf, java.lang.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(java.lang.String schema)Deprecated.voidsetSequence(java.lang.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 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: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 java.lang.Object nextInternal(JDBCStore store, ClassMapping mapping) throws java.sql.SQLException
Description copied from class:AbstractJDBCSeqReturn the next sequence object.- Specified by:
 nextInternalin classAbstractJDBCSeq- Throws:
 java.sql.SQLException
 
- 
allocateInternal
protected void allocateInternal(int additional, JDBCStore store, ClassMapping mapping) throws java.sql.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:
 java.sql.SQLException
 
- 
refreshSequence
public void refreshSequence() throws java.sql.SQLExceptionCreates the sequence in the DB.- Throws:
 java.sql.SQLException
 
- 
dropSequence
public void dropSequence() throws java.sql.SQLExceptionDrops the sequence in the DB.- Throws:
 java.sql.SQLException
 
- 
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionUsage: 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:
 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()
 
 - 
 
 -