Package com.logicaldoc.core.sequence

# 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

## Field Summary

### Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`void`
`delete(String name, long objectId, long tenantId)`
Deletes the sequence
`Sequence`
`findByAlternateKey(String name, long objectId, long tenantId)`
Finds the sequence by the given alternate key
`List<Sequence>`
`findByName(String name, long tenantId)`
Finds all sequences whose name starts with the passed name
`static SequenceDAO`
`get()`
Gets the object available in the application context
`long`
`getCurrentValue(String name, long objectId, long tenantId)`
Gets the current value
`long`
`next(String name, long objectId, long tenantId)`
Returns the next value of the sequence
`long`
`next(String name, long objectId, long tenantId, long increment)`
Returns the next value of the sequence by incrementing by the given increment
`void`
`reset(String name, long objectId, long tenantId, long value)`
Initializes the sequence value

### Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO

`bulkUpdate, count, count, count, delete, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, initialize, isMariaDB, isMySQL, isOracle, isPostgreSQL, isSQLServer, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, store`

## 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