Cumulus4j API
(1.1.0)

org.cumulus4j.store.model
Class Sequence2

java.lang.Object
  extended by org.cumulus4j.store.model.Sequence2

public class Sequence2
extends Object

Persistent sequence entity used by Cumulus4jIncrementGenerator.

Objects are cached by DataNucleus via their primary key. Accessing an object via its OID therefore does not require any query, if the object is already cached. Therefore, this class encodes the keyStoreRefID and the sequenceName together in one single sequenceID, which is the (single-field) primary key for this class.

We do not use a composite primary key, because this is not supported by all underlying databases. The chosen strategy is thus the most portable and fastest.

Since:
1.1.0
Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Constructor Summary
protected Sequence2()
          Default constructor.
protected Sequence2(int keyStoreRefID, String sequenceName)
          Constructor creating a Sequence with the given primary key.
 
Method Summary
protected static String createSequenceID(int keyStoreRefID, String sequenceName)
           
 int getKeyStoreRefID()
           
 long getNextValue()
          Get the next value (i.e.
 String getSequenceID()
           
 String getSequenceName()
          Get the name of the sequence.
 void setNextValue(long nextValue)
          Set the next value (i.e.
protected  String[] splitSequenceID()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sequence2

protected Sequence2()
Default constructor. Should never be used by actual code! It exists only to fulfill the JDO requirements.


Sequence2

protected Sequence2(int keyStoreRefID,
                    String sequenceName)
Constructor creating a Sequence with the given primary key.

Parameters:
sequenceName - the name of the sequence; must not be null.
Method Detail

createSequenceID

protected static String createSequenceID(int keyStoreRefID,
                                         String sequenceName)

getSequenceID

public String getSequenceID()

splitSequenceID

protected String[] splitSequenceID()

getKeyStoreRefID

public int getKeyStoreRefID()

getSequenceName

public String getSequenceName()
Get the name of the sequence.

Returns:
the name of the sequence.

getNextValue

public long getNextValue()
Get the next value (i.e. the first unused value) for this sequence.

Returns:
the next value (i.e. the first unused value) for this sequence.

setNextValue

public void setNextValue(long nextValue)
Set the next value (i.e. the first unused value) for this sequence.

Parameters:
nextValue - the next value (i.e. the first unused value) for this sequence.

Cumulus4j API
(1.1.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.