@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; }
@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; }
@Override public Project findProjectById(Project project) throws Exception { return (Project) super.findById(Project.class, project.getId()); }