Package com.logicaldoc.core.document

# Class HibernateVersionDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<Version>
com.logicaldoc.core.document.HibernateVersionDAO

All Implemented Interfaces:
  `VersionDAO`, `PersistentObjectDAO<Version>`

@Repository("versionDAO") public class HibernateVersionDAO extends HibernatePersistentObjectDAO<Version> implements VersionDAO
Hibernate implementation of `VersionDAO`

Since:
  3.0
Author:
  Marco Meschieri - LogicalDOC

## Field Summary

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

`ENTITY`

## Constructor Summary

Constructors
Constructor
Description
`HibernateVersionDAO()`

## Method Summary

Modifier and Type
Method
Description
`void`
`delete(long versionId, int delCode)`
This method deletes an entity and you can give a deletion code
`void`
`deleteAll(Collection<Version> entities, int code)`
Deletes all entries form the database giving a specific deletion code
`List<Version>`
`findByDocId(long docId)`
Finds all versions of the given document
`Version`
`findByFileVersion(long docId, String fileVersion)`
This method finds a the first version with the given fileVersion
`Version`
`findByVersion(long docId, String version)`
This method finds a version by the document's ID an the version code.
`void`
`initialize(Version version)`
Doesn't do anything by default
`void`
`store(Version version)`
This method persists the given version.
`void`
`updateDigest(Version version)`
Updates the version's digest (SHA-1)

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

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

### 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, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, isMariaDB, isMySQL, isOracle, isPostgreSQL, isSQLServer, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString`

## Constructor Details

### HibernateVersionDAO

public HibernateVersionDAO()

## Method Details

### findByDocId

public List<Version> findByDocId(long docId) throws PersistenceException
Description copied from interface: `VersionDAO`
Finds all versions of the given document

Specified by:
  `findByDocId` in interface `VersionDAO`
Parameters:
  `docId` - The document's id
Returns:
  The list of versions ordered by descending date
Throws:
  `PersistenceException` - Error in the database

### findByVersion

public Version findByVersion(long docId, String version) throws PersistenceException
Description copied from interface: `VersionDAO`
This method finds a version by the document's ID an the version code.

Specified by:
  `findByVersion` in interface `VersionDAO`
Parameters:
  `docId` - ID of the document
  `version` - the version code
Returns:
  the found version
Throws:
  `PersistenceException` - Error in the database

### findByFileVersion

public Version findByFileVersion(long docId, String fileVersion) throws PersistenceException
Description copied from interface: `VersionDAO`
This method finds a the first version with the given fileVersion

Specified by:
  `findByFileVersion` in interface `VersionDAO`
Parameters:
  `docId` - ID of the document
  `fileVersion` - the fileVersion code
Returns:
  the found version
Throws:
  `PersistenceException` - Error in the database

### initialize

public void initialize(Version version)
Description copied from class: `HibernatePersistentObjectDAO`
Doesn't do anything by default

Specified by:
  `initialize` in interface `PersistentObjectDAO<Version>`
Overrides:
  `initialize` in class `HibernatePersistentObjectDAO<Version>`
Parameters:
  `version` - The entity to be initialised

### store

public void store(Version version) throws PersistenceException
This method persists the given version. Checks if is necessary to delete some document versions reading the context property 'document.maxversions' and the maxVersions property of the owning workspace.

Specified by:
  `store` in interface `PersistentObjectDAO<Version>`
Overrides:
  `store` in class `HibernatePersistentObjectDAO<Version>`
Parameters:
  `version` - version to be stored.
Throws:
  `PersistenceException` - error at data layer

### updateDigest

public void updateDigest(Version version) throws PersistenceException
Description copied from interface: `VersionDAO`
Updates the version's digest (SHA-1)

Specified by:
  `updateDigest` in interface `VersionDAO`
Parameters:
  `version` - The version to be processed
Throws:
  `PersistenceException` - Error in the database

### delete

public void delete(long versionId, int delCode) 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<Version>`
Overrides:
  `delete` in class `HibernatePersistentObjectDAO<Version>`
Parameters:
  `versionId` - ID of the entity which should be deleted
  `delCode` - Deletion code
Throws:
  `PersistenceException` - raised in case of errors in the database

### deleteAll

public void deleteAll(Collection<Version> entities, int code) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
Deletes all entries form the database giving a specific deletion code

Specified by:
  `deleteAll` in interface `PersistentObjectDAO<Version>`
Overrides:
  `deleteAll` in class `HibernatePersistentObjectDAO<Version>`
Parameters:
  `entities` - The entities to be deleted
  `code` - The deletion code
Throws:
  `PersistenceException` - raised in case of errors in the database