org.apache.openjpa.jdbc.kernel
Class NativeJDBCSeq

java.lang.Object
  extended by org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
      extended by 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
static String ACTION_ADD
           
static String ACTION_DROP
           
static 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
NativeJDBCSeq()
           
 
Method Summary
 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 the JDBCConfiguration for this sequence.
 int getIncrement()
           
 int getInitialValue()
           
 String getSchema()
          Deprecated.  
 DBIdentifier getSchemaIdentifier()
           
 String getSequence()
          The sequence name.
static void main(String[] args)
          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 refreshSequence()
          Creates the sequence in the DB.
static boolean run(JDBCConfiguration conf, String[] args, Options opts)
          Run the tool.
static boolean run(JDBCConfiguration conf, String[] args, String action)
          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(String schema)
          Deprecated.  
 void setSequence(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, next, setType, suspendInJTA
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

NativeJDBCSeq

public NativeJDBCSeq()
Method Detail

getSequence

public String getSequence()
The sequence name. Defaults to OPENJPA_SEQUENCE.


setSequence

public void setSequence(String seqName)
The sequence name. Defaults to OPENJPA_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 interface JDBCSeq
Overrides:
addSchema in class AbstractJDBCSeq

getConfiguration

public JDBCConfiguration getConfiguration()
Description copied from class: AbstractJDBCSeq
Return the JDBCConfiguration for this sequence.

Specified by:
getConfiguration in class AbstractJDBCSeq

setConfiguration

public void setConfiguration(Configuration conf)
Description copied from interface: Configurable
Invoked prior to setting bean properties.

Specified by:
setConfiguration in interface Configurable

startConfiguration

public void startConfiguration()
Description copied from interface: Configurable
Invoked before bean property configuration is begun on this object.

Specified by:
startConfiguration in interface Configurable

endConfiguration

public void endConfiguration()
Description copied from interface: Configurable
Invoked upon completion of bean property configuration for this object.

Specified by:
endConfiguration in interface Configurable

nextInternal

protected Object nextInternal(JDBCStore store,
                              ClassMapping mapping)
                       throws SQLException
Description copied from class: AbstractJDBCSeq
Return the next sequence object.

Specified by:
nextInternal in class AbstractJDBCSeq
Throws:
SQLException

allocateInternal

protected void allocateInternal(int additional,
                                JDBCStore store,
                                ClassMapping mapping)
                         throws SQLException
Allocate additional sequence values.

Overrides:
allocateInternal in class AbstractJDBCSeq
Parameters:
additional - ignored - the allocation size is fixed and determined by allocate and increment properties.
store - used to obtain connection
mapping - ignored
Throws:
SQLException

refreshSequence

public void refreshSequence()
                     throws SQLException
Creates the sequence in the DB.

Throws:
SQLException

dropSequence

public void dropSequence()
                  throws SQLException
Drops 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. The various actions are as follows.

Throws:
Exception

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

public void setSchema(String schema)
Deprecated. 


getSchema

public String getSchema()
Deprecated. 


getSchemaIdentifier

public DBIdentifier getSchemaIdentifier()


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.