Save This Page
Home » apache-openjpa-1.1.0-source » org.apache.openjpa.jdbc » kernel » [javadoc | source]
org.apache.openjpa.jdbc.kernel
public class: TableJDBCSeq [javadoc | source]
java.lang.Object
   org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
      org.apache.openjpa.jdbc.kernel.TableJDBCSeq

All Implemented Interfaces:
    Configurable, JDBCSeq

Direct Known Subclasses:
    ValueTableJDBCSeq, ClassTableJDBCSeq

JDBCSeq implementation that uses a database table for sequence number generation. This base implementation uses a single row for a global sequence number.
Nested Class Summary:
protected static class  TableJDBCSeq.Status  Helper struct to hold status information. 
Field Summary
public static final  String ACTION_DROP     
public static final  String ACTION_ADD     
public static final  String ACTION_GET     
public static final  String ACTION_SET     
Fields inherited from org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq:
type,  current
Method from org.apache.openjpa.jdbc.kernel.TableJDBCSeq Summary:
addPrimaryKeyColumn,   addSchema,   allocateInternal,   currentInternal,   dropTable,   endConfiguration,   executeQuery,   executeUpdate,   getAllocate,   getConfiguration,   getInitialValue,   getPrimaryKey,   getPrimaryKeyColumn,   getSequence,   getSequence,   getSequenceColumn,   getStatus,   getTable,   main,   nextInternal,   prepareStatement,   refreshTable,   resolveTableName,   run,   run,   setAllocate,   setConfiguration,   setIncrement,   setInitialValue,   setPrimaryKeyColumn,   setSequence,   setSequenceColumn,   setTable,   setTableName,   startConfiguration
Methods from org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq:
addSchema,   allocate,   allocateInternal,   close,   closeConnection,   current,   currentInternal,   getConfiguration,   getConnection,   next,   nextInternal,   setType,   suspendInJTA
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.openjpa.jdbc.kernel.TableJDBCSeq Detail:
 protected Column addPrimaryKeyColumn(Table table) 
    Add the primary key column to the given table and return it.
 public  void addSchema(ClassMapping mapping,
    SchemaGroup group) 
 protected  void allocateInternal(int count,
    JDBCStore store,
    ClassMapping mapping) throws SQLException 
 protected Object currentInternal(JDBCStore store,
    ClassMapping mapping) throws Exception 
 public  void dropTable() throws SQLException 
    Drops the sequence table in the DB.
 public  void endConfiguration() 
 protected ResultSet executeQuery(JDBCConfiguration conf,
    Connection conn,
    PreparedStatement stmnt,
    SQLBuffer buf) throws SQLException 
    This method is to provide override for non-JDBC or JDBC-like implementation of executing query.
 protected int executeUpdate(JDBCConfiguration conf,
    Connection conn,
    PreparedStatement stmnt,
    SQLBuffer buf,
    int opcode) throws SQLException 
    This method is to provide override for non-JDBC or JDBC-like implementation of executing update.
 public int getAllocate() 
    Return the number of sequences to allocate for each update of the sequence table. Sequence numbers will be grabbed in blocks of this value to reduce the number of transactions that must be performed on the sequence table.
 public JDBCConfiguration getConfiguration() 
 public int getInitialValue() 
    Return the number as the initial number for the GeneratedValue.TABLE strategy to start with.
 protected Object getPrimaryKey(ClassMapping mapping) 
    Return the primary key value for the given class.
 public String getPrimaryKeyColumn() 
    The name of the table's primary key column. Defaults to ID.
 protected long getSequence(ClassMapping mapping,
    Connection conn) throws SQLException 
    Return the current sequence value, or -1 if unattainable.
 protected long getSequence(ResultSet rs,
    DBDictionary dict) throws SQLException 
    This method is to provide override for non-JDBC or JDBC-like implementation of getting sequence from the result set.
 public String getSequenceColumn() 
    The name of the column that holds the sequence value. Defaults to SEQUENCE_VALUE.
 protected TableJDBCSeq.Status getStatus(ClassMapping mapping) 
    Return the appropriate status object for the given class, or null if cannot handle the given class. The mapping may be null.
 public String getTable() 
    The sequence table name. Defaults to OPENJPA_SEQUENCE_TABLE. By default, the table will be placed in the first schema listed in your openjpa.jdbc.Schemas property, or in the default schema if the property is not given. If you specify a table name in the form <schema>.<table>, then the given schema will be used.
 public static  void main(String[] args) throws Exception 
    Usage: java org.apache.openjpa.jdbc.schema.TableJDBCSequence [option]* -action/-a <add | drop | get | set> [value] Where the following options are recognized.
    • -properties/-p <properties file or resource>: The path or resource name of a OpenJPA properties file containing information such as the license key and 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. For example: -licenseKey adslfja83r3lkadf
    The various actions are as follows.
    • add: Create the sequence table.
    • drop: Drop the sequence table.
    • get: Print the current sequence value.
    • set: Set the sequence value.
 protected Object nextInternal(JDBCStore store,
    ClassMapping mapping) throws Exception 
 protected PreparedStatement prepareStatement(Connection conn,
    SQLBuffer buf) throws SQLException 
    This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.
 public  void refreshTable() throws SQLException 
    Creates the sequence table in the DB.
 public String resolveTableName(ClassMapping mapping,
    Table table) 
    Resolve a fully qualified table name
 public static boolean run(JDBCConfiguration conf,
    String[] args,
    Options opts) throws Exception 
    Run the tool. Returns false if invalid options were given.
 public static boolean run(JDBCConfiguration conf,
    String[] args,
    String action) throws Exception 
    Run the tool. Return false if an invalid option was given.
 public  void setAllocate(int alloc) 
    Return the number of sequences to allocate for each update of the sequence table. Sequence numbers will be grabbed in blocks of this value to reduce the number of transactions that must be performed on the sequence table.
 public  void setConfiguration(Configuration conf) 
 public  void setIncrement(int inc) 
Deprecated! Use - #setAllocate . Retained for backwards compatibility of auto-configuration.

 public  void setInitialValue(int intValue) 
    Set the initial number in the table for the GeneratedValue.TABLE strategy to use as initial number.
 public  void setPrimaryKeyColumn(String primaryKeyColumn) 
    The name of the table's primary key column. Defaults to ID.
 protected boolean setSequence(ClassMapping mapping,
    TableJDBCSeq.Status stat,
    int inc,
    boolean updateStatSeq,
    Connection conn) throws SQLException 
    Grabs the next handful of sequence numbers.
 public  void setSequenceColumn(String sequenceColumn) 
    The name of the column that holds the sequence value. Defaults to SEQUENCE_VALUE.
 public  void setTable(String name) 
    The sequence table name. Defaults to OPENJPA_SEQUENCE_TABLE. By default, the table will be placed in the first schema listed in your openjpa.jdbc.Schemas property, or in the default schema if the property is not given. If you specify a table name in the form <schema>.<table>, then the given schema will be used.
 public  void setTableName(String name) 
Deprecated! Use - #setTable . Retained for backwards-compatibility with auto-configuration.

 public  void startConfiguration()