org.datanucleus.store.rdbms.table
Class SequenceTable

java.lang.Object
  extended by org.datanucleus.store.rdbms.table.AbstractTable
      extended by org.datanucleus.store.rdbms.table.TableImpl
          extended by org.datanucleus.store.rdbms.table.SequenceTable
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreContainerObject, Table

public class SequenceTable
extends TableImpl

Class defining a table for storing generated values. The table has 2 columns : a primary key String, and a value Long.


Field Summary
 
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByName, dba, existsInDatastore, identifier, LOCALISER, state, storeMgr
 
Constructor Summary
SequenceTable(org.datanucleus.store.mapped.DatastoreIdentifier identifier, RDBMSManager storeMgr, java.lang.String seqNameColName, java.lang.String nextValColName)
          Constructor
 
Method Summary
 void deleteAllSequences(org.datanucleus.ManagedConnection conn)
          Method to delete all sequences
 void deleteSequence(java.lang.String sequenceName, org.datanucleus.ManagedConnection conn)
          Method to delete a sequence
 java.util.HashSet getFetchAllSequences(org.datanucleus.ManagedConnection conn)
          Accessor for the sequences
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getIDMapping()
          Accessor for a mapping for the ID (PersistenceCapable) for this table.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          Accessor the for the mapping for a field store in this table
 java.lang.Long getNextVal(java.lang.String sequenceName, org.datanucleus.ManagedConnection conn, int incrementBy, org.datanucleus.store.mapped.DatastoreIdentifier tableIdentifier, java.lang.String columnName, int initialValue)
          Accessor for the nextval of a sequence
 void initialize(org.datanucleus.ClassLoaderResolver clr)
          Method to initialise the table.
 
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getPrimaryKey, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, postInitialize, preInitialize, validate, validateColumns, validateConstraints, validatePrimaryKey
 
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumnInternal, addDatastoreField, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getDatastoreField, getDatastoreFields, getDatastoreIdentifierFullyQualified, getDiscriminatorMapping, getDiscriminatorMetaData, getIdentifier, getSchemaName, getStoreManager, getVersionMapping, getVersionMetaData, hasColumnName, hasDatastoreField, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, tableExistsInDatastore, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequenceTable

public SequenceTable(org.datanucleus.store.mapped.DatastoreIdentifier identifier,
                     RDBMSManager storeMgr,
                     java.lang.String seqNameColName,
                     java.lang.String nextValColName)
Constructor

Parameters:
identifier - Datastore identifier for this table
storeMgr - The RDBMSManager for this datastore
seqNameColName - Name for the "sequence name" column
nextValColName - Name for the "next value" column
Method Detail

initialize

public void initialize(org.datanucleus.ClassLoaderResolver clr)
Method to initialise the table.

Parameters:
clr - The ClassLoaderResolver

getIDMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getIDMapping()
Accessor for a mapping for the ID (PersistenceCapable) for this table.

Returns:
The (PersistenceCapable) ID mapping.

getFetchAllSequences

public java.util.HashSet getFetchAllSequences(org.datanucleus.ManagedConnection conn)
                                       throws java.sql.SQLException
Accessor for the sequences

Parameters:
conn - Connection for this datastore.
Returns:
The HashSet of Sequence names
Throws:
java.sql.SQLException - Thrown when an error occurs in the process.

getNextVal

public java.lang.Long getNextVal(java.lang.String sequenceName,
                                 org.datanucleus.ManagedConnection conn,
                                 int incrementBy,
                                 org.datanucleus.store.mapped.DatastoreIdentifier tableIdentifier,
                                 java.lang.String columnName,
                                 int initialValue)
                          throws java.sql.SQLException
Accessor for the nextval of a sequence

Parameters:
conn - Connection for this datastore.
sequenceName - The sequence name (the key)
incrementBy - The amount to increment (from the current value)
tableIdentifier - Identifier for the table being incremented (used when there is no current value)
columnName - Name of the column being incremented (used when there is no current value)
initialValue - Initial value (if not using tableIdentifier/columnName to find the initial value)
Returns:
The next value that should be used
Throws:
java.sql.SQLException - Thrown when an error occurs in the process.

deleteSequence

public void deleteSequence(java.lang.String sequenceName,
                           org.datanucleus.ManagedConnection conn)
                    throws java.sql.SQLException
Method to delete a sequence

Parameters:
sequenceName -
conn - Connection to the datastore
Throws:
java.sql.SQLException - Thrown when an error occurs deleting the schema.

deleteAllSequences

public void deleteAllSequences(org.datanucleus.ManagedConnection conn)
                        throws java.sql.SQLException
Method to delete all sequences

Parameters:
conn - Connection to the datastore
Throws:
java.sql.SQLException - Thrown when an error occurs deleting.

getMemberMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor the for the mapping for a field store in this table

Parameters:
mmd - MetaData for the field whose mapping we want
Returns:
The mapping


Copyright © 2009. All Rights Reserved.