net.sf.derquinsej.hib3.seq
Class SequenceDAO

java.lang.Object
  extended by net.sf.derquinsej.hib3.seq.SequenceDAO

public class SequenceDAO
extends Object

Data access object for the sequence entity. As it represents a very specific case, it does not follow normal best-practices (interface-based, etc.). WARNING: Transactional sequences are a source of locks and may hurt scalability.

Author:
Andres Rodriguez

Constructor Summary
SequenceDAO(SessionFactory sessionFactory)
          Initialized the DAO
 
Method Summary
 long getCurrentValue(String id)
          Gets the current value of a sequence.
 long getNextValue(String id)
          Gets the next value of a sequence.
 long getNextValue(String id, long initial, long increment)
          Gets the next value of a sequence, creating it if it does not exist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceDAO

public SequenceDAO(SessionFactory sessionFactory)
Initialized the DAO

Parameters:
sessionFactory - Hibernate Session factory.
Method Detail

getCurrentValue

public long getCurrentValue(String id)
                     throws SequenceNotFoundException
Gets the current value of a sequence.

Parameters:
id - Sequence name.
Returns:
The current value of the specified sequence.
Throws:
SequenceNotFoundException - if the sequence is not found.

getNextValue

public long getNextValue(String id)
                  throws SequenceNotFoundException
Gets the next value of a sequence. The row is locked in the current transaction.

Parameters:
id - Sequence name.
Returns:
The next value of the specified sequence.
Throws:
SequenceNotFoundException - if the sequence is not found.

getNextValue

public long getNextValue(String id,
                         long initial,
                         long increment)
Gets the next value of a sequence, creating it if it does not exist.

Parameters:
id - Sequence name.
initial - Initial value.
increment - Increment between values.
Returns:
The next value of the specified sequence.


Copyright © 2012. All Rights Reserved.