Interface SequenceDAO

All Superinterfaces:
PersistentObjectDAO<Sequence>
All Known Implementing Classes:
HibernateSequenceDAO

public interface SequenceDAO extends PersistentObjectDAO<Sequence>
Utility DAO that can manage sequences persisted in the DB

Important: Implementations of this interface must grant synchronization.

Since:
4.0
Author:
Matteo Caruso - LogicalDOC
  • Method Details

    • get

      static SequenceDAO get()
      Gets the object available in the application context
      Returns:
      the instance of this object in the application context
    • next

      long next(String name, long objectId, long tenantId) throws PersistenceException
      Returns the next value of the sequence
      Parameters:
      name - name of the sequence
      objectId - The sequence object ID
      tenantId - ID of the owning tenant
      Returns:
      The next value
      Throws:
      PersistenceException - an error happened in the database
    • next

      long next(String name, long objectId, long tenantId, long increment) throws PersistenceException
      Returns the next value of the sequence by incrementing by the given increment
      Parameters:
      name - name of the sequence
      objectId - The sequence object ID
      tenantId - ID of the owning tenant
      increment - ID of the owning tenant
      Returns:
      The next value
      Throws:
      PersistenceException - an error happened in the database
    • reset

      void reset(String name, long objectId, long tenantId, long value) throws PersistenceException
      Initializes the sequence value
      Parameters:
      name - name of the sequence
      objectId - The sequence object ID
      tenantId - ID of the owning tenant
      value - The initial value
      Throws:
      PersistenceException - an error happened in the database
    • delete

      void delete(String name, long objectId, long tenantId) throws PersistenceException
      Deletes the sequence
      Parameters:
      name - name of the sequence
      objectId - value for the objectId field
      tenantId - identifier of the tenant
      Throws:
      PersistenceException - if a database error occurs
    • findByName

      List<Sequence> findByName(String name, long tenantId) throws PersistenceException
      Finds all sequences whose name starts with the passed name
      Parameters:
      name - name of the sequence
      tenantId - identifier of the tenant
      Returns:
      collection of sequences
      Throws:
      PersistenceException
    • findByAlternateKey

      Sequence findByAlternateKey(String name, long objectId, long tenantId) throws PersistenceException
      Finds the sequence by the given alternate key
      Parameters:
      name - name of the sequence
      objectId - value for the objectId field
      tenantId - identifier of the tenant
      Returns:
      the sequence object
      Throws:
      PersistenceException
    • getCurrentValue

      long getCurrentValue(String name, long objectId, long tenantId) throws PersistenceException
      Gets the current value
      Parameters:
      name - name of the sequence
      objectId - value for the objectId field
      tenantId - identifier of the tenant
      Returns:
      current value of the sequence
      Throws:
      PersistenceException - an error happened in the database