View Javadoc
1   package org.itracker.persistence.dao;
2   
3   import org.hibernate.HibernateException;
4   import org.hibernate.Query;
5   import org.itracker.model.IssueActivity;
6   
7   import java.util.List;
8   
9   /**
10   *
11   */
12  public class IssueActivityDAOImpl extends BaseHibernateDAOImpl<IssueActivity>
13          implements IssueActivityDAO {
14  
15      public IssueActivityDAOImpl() {
16      }
17  
18      public IssueActivity findById(Integer activityId) {
19          IssueActivity activity;
20          try {
21              activity = (IssueActivity) getSession().get(IssueActivity.class,
22                      activityId);
23          } catch (HibernateException ex) {
24              throw convertHibernateAccessException(ex);
25          }
26          return activity;
27      }
28  
29      @SuppressWarnings("unchecked")
30      public List<IssueActivity> findByIssueId(Integer issueId) {
31          List<IssueActivity> activities;
32  
33          try {
34              Query query = getSession().getNamedQuery(
35                      "IssueActivitiesByIssueQuery");
36              query.setInteger("issueId", issueId);
37              activities = query.list();
38          } catch (HibernateException ex) {
39              throw convertHibernateAccessException(ex);
40          }
41          return activities;
42      }
43  
44      @SuppressWarnings("unchecked")
45      public List<IssueActivity> findByIssueIdAndNotification(Integer issueId,
46                                                              boolean notificationSent) {
47          List<IssueActivity> activities;
48  
49          try {
50              Query query = getSession().getNamedQuery(
51                      "IssueActivitiesByIssueAndNotificationQuery");
52              query.setInteger("issueId", issueId);
53              query.setBoolean("notificationSent", notificationSent);
54              activities = query.list();
55          } catch (HibernateException ex) {
56              throw convertHibernateAccessException(ex);
57          }
58          return activities;
59      }
60  
61  
62  }