コード例 #1
0
ファイル: ProjectDaoImpl.java プロジェクト: houzhenggang/pm
 @SuppressWarnings("unchecked")
 @Override
 public int findCountOfPro(User user, String status) throws Exception {
   int count = 0;
   String hql = "from Project p where p.status = ?0";
   List<Project> projects =
       super.getEntityManager().createQuery(hql).setParameter(0, status).getResultList();
   for (Project project : projects) {
     List<ProjectMember> pms = project.getProjectMembers();
     for (ProjectMember pm : pms) if (pm.getId().getUser().getId().equals(user.getId())) count++;
   }
   return count;
 }
コード例 #2
0
ファイル: ProjectDaoImpl.java プロジェクト: houzhenggang/pm
 @SuppressWarnings("unchecked")
 @Override
 public List<Project> findByUser(User user, String status) throws Exception {
   String hql = "from Project p where p.status = ?0";
   List<Project> list = new ArrayList<Project>();
   List<Project> projects =
       super.getEntityManager().createQuery(hql).setParameter(0, status).getResultList();
   for (Project project : projects) {
     List<ProjectMember> pms = project.getProjectMembers();
     for (ProjectMember pm : pms)
       if (pm.getId().getUser().getId().equals(user.getId())) list.add(project);
   }
   return list;
 }
コード例 #3
0
ファイル: ProjectDaoImpl.java プロジェクト: houzhenggang/pm
 @SuppressWarnings("unchecked")
 @Override
 public List<Project> pagingFindByUser(User user, PageUtil pageUtil) throws Exception {
   String hql =
       "from Project p, ProjectMember pm where pm.id.user.id = ?0 and pm.id.project.id = p.id order by p.createTime desc";
   List<Project> projects = new ArrayList<Project>();
   List<Object> objs =
       super.getEntityManager()
           .createQuery(hql)
           .setParameter(0, user.getId())
           .setFirstResult(pageUtil.getCurrentPageBeginNo())
           .setMaxResults(pageUtil.getEachPageMaxSize())
           .getResultList();
   Iterator<Object> iterator = objs.iterator();
   while (iterator.hasNext()) {
     Object[] objects = (Object[]) iterator.next();
     Project project = (Project) objects[0];
     projects.add(project);
   }
   return projects;
 }