View Javadoc
1   package org.itracker.persistence.dao;
2   
3   import org.hibernate.HibernateException;
4   import org.hibernate.Query;
5   import org.itracker.model.Notification;
6   
7   import java.util.List;
8   
9   /**
10   *
11   */
12  public class NotificationDAOImpl
13          extends BaseHibernateDAOImpl<Notification>
14          implements NotificationDAO {
15  
16      public NotificationDAOImpl() {
17      }
18  
19      public Notification findById(Integer id) {
20          Notification notification;
21  
22          try {
23              notification = (Notification) getSession().get(Notification.class, id);
24          } catch (HibernateException ex) {
25              throw convertHibernateAccessException(ex);
26          }
27          return notification;
28      }
29  
30      @SuppressWarnings("unchecked")
31      public List<Notification> findByIssueId(Integer issueId) {
32          List<Notification> notifications;
33  
34          try {
35              Query query = getSession().getNamedQuery(
36                      "NotificationsByIssueQuery");
37              query.setInteger("issueId", issueId);
38              notifications = query.list();
39          } catch (HibernateException ex) {
40              throw convertHibernateAccessException(ex);
41          }
42          return notifications;
43      }
44  
45  }