org.datanucleus.store.rdbms.valuegenerator
Class SequenceGenerator

java.lang.Object
  extended by org.datanucleus.store.valuegenerator.AbstractGenerator
      extended by org.datanucleus.store.valuegenerator.AbstractDatastoreGenerator
          extended by org.datanucleus.store.rdbms.valuegenerator.AbstractRDBMSGenerator
              extended by org.datanucleus.store.rdbms.valuegenerator.SequenceGenerator
All Implemented Interfaces:
org.datanucleus.store.valuegenerator.ValueGenerator

public final class SequenceGenerator
extends AbstractRDBMSGenerator

This generator utilises datastore sequences. It uses a statement like

"select .nextval from dual"
to get the next value in the sequence. It is datastore-dependent since there is no RDBMS-independent statement. SequencePoidGenerator works with numbers, so clients using this generator must cast the ID to Long

Required user properties

Optional user properties


Field Summary
protected  java.lang.String sequenceName
          Name of the sequence that we are creating values for
 
Fields inherited from class org.datanucleus.store.rdbms.valuegenerator.AbstractRDBMSGenerator
connection, LOCALISER_RDBMS
 
Fields inherited from class org.datanucleus.store.valuegenerator.AbstractDatastoreGenerator
connectionProvider, storeMgr
 
Fields inherited from class org.datanucleus.store.valuegenerator.AbstractGenerator
allocationSize, block, initialValue, LOCALISER, name, properties, repositoryExists
 
Constructor Summary
SequenceGenerator(java.lang.String name, java.util.Properties props)
          Constructor.
 
Method Summary
protected  boolean createRepository()
          Method to create the sequence.
protected  java.lang.String getSequenceName()
          Accessor for the sequence name to use (fully qualified with catalog/schema).
protected  boolean repositoryExists()
          Method to return if the repository already exists.
protected  boolean requiresRepository()
          Indicator for whether the generator requires its own repository.
protected  org.datanucleus.store.valuegenerator.ValueGenerationBlock reserveBlock(long size)
          Reserve a block of ids.
 
Methods inherited from class org.datanucleus.store.rdbms.valuegenerator.AbstractRDBMSGenerator
obtainGenerationBlock, requiresConnection
 
Methods inherited from class org.datanucleus.store.valuegenerator.AbstractDatastoreGenerator
setConnectionProvider, setStoreManager
 
Methods inherited from class org.datanucleus.store.valuegenerator.AbstractGenerator
allocate, current, currentValue, getName, getStorageClass, next, nextValue, obtainGenerationBlock, reserveBlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequenceName

protected java.lang.String sequenceName
Name of the sequence that we are creating values for

Constructor Detail

SequenceGenerator

public SequenceGenerator(java.lang.String name,
                         java.util.Properties props)
Constructor.

Parameters:
name - Symbolic name for the generator
props - Properties controlling the behaviour of the generator
Method Detail

reserveBlock

protected org.datanucleus.store.valuegenerator.ValueGenerationBlock reserveBlock(long size)
Reserve a block of ids.

Specified by:
reserveBlock in class org.datanucleus.store.valuegenerator.AbstractGenerator
Parameters:
size - Block size
Returns:
The reserved block

getSequenceName

protected java.lang.String getSequenceName()
Accessor for the sequence name to use (fully qualified with catalog/schema).

Returns:
The sequence name

requiresRepository

protected boolean requiresRepository()
Indicator for whether the generator requires its own repository. This class needs a repository so returns true.

Overrides:
requiresRepository in class org.datanucleus.store.valuegenerator.AbstractGenerator
Returns:
Whether a repository is required.

repositoryExists

protected boolean repositoryExists()
Method to return if the repository already exists.

Overrides:
repositoryExists in class org.datanucleus.store.valuegenerator.AbstractGenerator
Returns:
Whether the repository exists

createRepository

protected boolean createRepository()
Method to create the sequence.

Overrides:
createRepository in class org.datanucleus.store.valuegenerator.AbstractGenerator
Returns:
Whether it was created successfully.


Copyright © 2009. All Rights Reserved.