NotificationDAOImpl.java

  1. package org.itracker.persistence.dao;

  2. import org.hibernate.HibernateException;
  3. import org.hibernate.Query;
  4. import org.itracker.model.Notification;

  5. import java.util.List;

  6. /**
  7.  *
  8.  */
  9. public class NotificationDAOImpl
  10.         extends BaseHibernateDAOImpl<Notification>
  11.         implements NotificationDAO {

  12.     public NotificationDAOImpl() {
  13.     }

  14.     public Notification findById(Integer id) {
  15.         Notification notification;

  16.         try {
  17.             notification = (Notification) getSession().get(Notification.class, id);
  18.         } catch (HibernateException ex) {
  19.             throw convertHibernateAccessException(ex);
  20.         }
  21.         return notification;
  22.     }

  23.     @SuppressWarnings("unchecked")
  24.     public List<Notification> findByIssueId(Integer issueId) {
  25.         List<Notification> notifications;

  26.         try {
  27.             Query query = getSession().getNamedQuery(
  28.                     "NotificationsByIssueQuery");
  29.             query.setInteger("issueId", issueId);
  30.             notifications = query.list();
  31.         } catch (HibernateException ex) {
  32.             throw convertHibernateAccessException(ex);
  33.         }
  34.         return notifications;
  35.     }

  36. }