Package com.logicaldoc.core.sequence

# Class HibernateSequenceDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<Sequence>
com.logicaldoc.core.sequence.HibernateSequenceDAO

All Implemented Interfaces:
  `PersistentObjectDAO<Sequence>`, `SequenceDAO`

@Repository("sequenceDAO") public class HibernateSequenceDAO extends HibernatePersistentObjectDAO<Sequence> implements SequenceDAO
Hibernate implementation of `SequenceDAO`.
Sequences are implemented ad Generics whose type is 'sequence' and subtype is the sequence name.

Since:
  4.0
Author:
  Marco Meschieri - LogicalDOC

## Field Summary

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

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`void`
`delete(long id, int code)`
This method deletes an entity and you can give a deletion code
`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
`long`
`getCurrentValue(String sequence, long objectId, long tenantId)`
Gets the current value
`long`
`next(String sequence, long objectId, long tenantId)`
Returns the next value of the sequence
`long`
`next(String sequence, long objectId, long tenantId, long increment)`
Returns the next value of the sequence by incrementing by the given increment
`void`
`reset(String sequence, long objectId, long tenantId, long value)`
Initializes the sequence value

### Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO

`bulkUpdate, count, deleteAll, evict, evict, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findIdsByWhere, getDatabaseMetadata, initialize, jdbcUpdate, jdbcUpdate, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, setSessionFactory, store`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

`bulkUpdate, count, count, count, 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

### reset

public void reset(String sequence, long objectId, long tenantId, long value) throws PersistenceException
Description copied from interface: `SequenceDAO`
Initializes the sequence value

Specified by:
  `reset` in interface `SequenceDAO`
Parameters:
  `sequence` - 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

### next

public long next(String sequence, long objectId, long tenantId, long increment) throws PersistenceException
Description copied from interface: `SequenceDAO`
Returns the next value of the sequence by incrementing by the given increment

Specified by:
  `next` in interface `SequenceDAO`
Parameters:
  `sequence` - 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

### next

public long next(String sequence, long objectId, long tenantId) throws PersistenceException
Description copied from interface: `SequenceDAO`
Returns the next value of the sequence

Specified by:
  `next` in interface `SequenceDAO`
Parameters:
  `sequence` - 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

### getCurrentValue

public long getCurrentValue(String sequence, long objectId, long tenantId) throws PersistenceException
Description copied from interface: `SequenceDAO`
Gets the current value

Specified by:
  `getCurrentValue` in interface `SequenceDAO`
Parameters:
  `sequence` - 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

### findByName

public List<Sequence> findByName(String name, long tenantId)
Description copied from interface: `SequenceDAO`
Finds all sequences whose name starts with the passed name

Specified by:
  `findByName` in interface `SequenceDAO`
Parameters:
  `name` - name of the sequence
  `tenantId` - identifier of the tenant
Returns:
  collection of sequences

### findByAlternateKey

public Sequence findByAlternateKey(String name, long objectId, long tenantId) throws PersistenceException
Description copied from interface: `SequenceDAO`
Finds the sequence by the given alternate key

Specified by:
  `findByAlternateKey` in interface `SequenceDAO`
Parameters:
  `name` - name of the sequence
  `objectId` - value for the objectId field
  `tenantId` - identifier of the tenant
Returns:
  the sequence object
Throws:
  `PersistenceException`

### delete

public void delete(String name, long objectId, long tenantId) throws PersistenceException
Description copied from interface: `SequenceDAO`
Deletes the sequence

Specified by:
  `delete` in interface `SequenceDAO`
Parameters:
  `name` - name of the sequence
  `objectId` - value for the objectId field
  `tenantId` - identifier of the tenant
Throws:
  `PersistenceException` - if a database error occurs

### delete

public void delete(long id, int code) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
This method deletes an entity and you can give a deletion code

Specified by:
  `delete` in interface `PersistentObjectDAO<Sequence>`
Overrides:
  `delete` in class `HibernatePersistentObjectDAO<Sequence>`
Parameters:
  `id` - ID of the entity which should be deleted
  `code` - Deletion code
Throws:
  `PersistenceException` - raised in case of errors in the database