Package com.logicaldoc.core.communication

# Class HibernateSystemMessageDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<SystemMessage>
com.logicaldoc.core.communication.HibernateSystemMessageDAO

All Implemented Interfaces:
  `SystemMessageDAO`, `PersistentObjectDAO<SystemMessage>`

@Repository("systemMessageDAO") public class HibernateSystemMessageDAO extends HibernatePersistentObjectDAO<SystemMessage> implements SystemMessageDAO
Hibernate implementation of `SystemMessageDAO`

Since:
  3.0
Author:
  Marco Meschieri - LogicalDOC

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`class`
`HibernateSystemMessageDAO.SystemMessageMapper`

## Field Summary

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

`ENTITY`

## Constructor Summary

Constructors
Constructor
Description
`HibernateSystemMessageDAO()`

## Method Summary

Modifier and Type
Method
Description
`void`
`deleteExpiredMessages(int type)`
Removes all expired messages for the specified type
`void`
`deleteExpiredMessages(String recipient)`
Removes all system expired messages for the specified recipient
`List<SystemMessage>`
`findByMode(String mode)`
This method selects all the messages for the specified mode
`List<SystemMessage>`
`findByRecipient(String recipient, int type, Integer read)`
This method selects all the messages for the specified recipient and type
`List<SystemMessage>`
`findByType(int type)`
This method selects all the messages for the specified type
`List<SystemMessage>`
`findMessagesToBeSent(int type, int maxTrial)`
This method selects all the messages for the specified type that are not been already sent and for which the number of sending trials is less than the maximum number (parameter 'notifier.maxtrials')
`int`
`getUnreadCount(String recipient, int type)`
This methods gets the number of unread messages for the specified recipient and type.
`void`
`initialize(SystemMessage message)`
Doesn't do anything by default
`void`
`store(SystemMessage message)`
This method persists the entity object

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

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

### HibernateSystemMessageDAO

public HibernateSystemMessageDAO()

## Method Details

### findByRecipient

public List<SystemMessage> findByRecipient(String recipient, int type, Integer read) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
This method selects all the messages for the specified recipient and type

Specified by:
  `findByRecipient` in interface `SystemMessageDAO`
Parameters:
  `recipient` - The recipient name
  `type` - The message type
  `read` - Optional flag
Returns:
  The messages list
Throws:
  `PersistenceException` - @throws PersistenceException Error in the database

### getUnreadCount

public int getUnreadCount(String recipient, int type) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
This methods gets the number of unread messages for the specified recipient and type.

Specified by:
  `getUnreadCount` in interface `SystemMessageDAO`
Parameters:
  `recipient` - The recipient name
  `type` - The message type
Returns:
  The number of messages
Throws:
  `PersistenceException` - Error in the database

### deleteExpiredMessages

public void deleteExpiredMessages(String recipient) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
Removes all system expired messages for the specified recipient

Specified by:
  `deleteExpiredMessages` in interface `SystemMessageDAO`
Parameters:
  `recipient` - The recipient
Throws:
  `PersistenceException` - Error in the database

### deleteExpiredMessages

public void deleteExpiredMessages(int type) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
Removes all expired messages for the specified type

Specified by:
  `deleteExpiredMessages` in interface `SystemMessageDAO`
Parameters:
  `type` - The message type
Throws:
  `PersistenceException` - Error in the database

### findByMode

public List<SystemMessage> findByMode(String mode) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
This method selects all the messages for the specified mode

Specified by:
  `findByMode` in interface `SystemMessageDAO`
Parameters:
  `mode` - The message mode
Returns:
  The list of messages of the given mode
Throws:
  `PersistenceException` - Error in the database

### findByType

public List<SystemMessage> findByType(int type) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
This method selects all the messages for the specified type

Specified by:
  `findByType` in interface `SystemMessageDAO`
Parameters:
  `type` - type of the message
Returns:
  The list of messages with the given type
Throws:
  `PersistenceException` - Error in the database

### initialize

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

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

### findMessagesToBeSent

public List<SystemMessage> findMessagesToBeSent(int type, int maxTrial) throws PersistenceException
Description copied from interface: `SystemMessageDAO`
This method selects all the messages for the specified type that are not been already sent and for which the number of sending trials is less than the maximum number (parameter 'notifier.maxtrials')

Specified by:
  `findMessagesToBeSent` in interface `SystemMessageDAO`
Parameters:
  `type` - The message type
  `maxTrial` - The maximum number of sending trials
Returns:
  The list of messages of the given type
Throws:
  `PersistenceException` - Error in the database

### store

public void store(SystemMessage message) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
This method persists the entity object

Specified by:
  `store` in interface `PersistentObjectDAO<SystemMessage>`
Overrides:
  `store` in class `HibernatePersistentObjectDAO<SystemMessage>`
Parameters:
  `message` - entity to be stored
Throws:
  `PersistenceException` - raised in case of errors in the database