List of usage examples for org.hibernate Criteria setFetchMode
public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;
From source file:es.sm2.openppm.core.dao.ProgramDAO.java
License:Open Source License
/** * Search programs by filters//from w w w. j a v a 2 s . c om * @param list * @param properyOrder * @param typeOrder * @param joins * @return */ @SuppressWarnings("unchecked") public List<Program> findByFilters(ArrayList<PropertyRelation> list, String propertyOrder, String typeOrder, List<String> joins) { Criteria crit = getSession().createCriteria(getPersistentClass()); if (joins != null) { for (String join : joins) { crit.setFetchMode(join, FetchMode.JOIN); } } for (PropertyRelation propertyRelation : list) { crit.add(findRestriction(propertyRelation)); } addOrder(crit, propertyOrder, typeOrder); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectActivityDAO.java
License:Open Source License
/** * List of activities by project//from w w w . j a v a2 s .c o m * * @param proj * @return */ @SuppressWarnings("unchecked") public List<Projectactivity> findByProject(Project proj, List<String> joins) { List<Projectactivity> list = null; if (proj != null) { Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Projectactivity.PROJECT, proj)); if (joins != null) { for (String join : joins) { crit.setFetchMode(join, FetchMode.JOIN); } } // Order crit.addOrder(Order.asc(Projectactivity.ACTIVITYNAME)); list = crit.list(); } return list; }
From source file:es.sm2.openppm.core.dao.ProjectCostsDAO.java
License:Open Source License
/** * Return Project costs//from w w w .j a v a 2 s. c om * @param proj * @return */ @SuppressWarnings("unchecked") public List<Projectcosts> findByProject(Project proj) { List<Projectcosts> costs = null; if (proj != null) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("directcostses", FetchMode.JOIN); crit.setFetchMode("directcostses.budgetaccounts", FetchMode.JOIN); crit.setFetchMode("expenseses", FetchMode.JOIN); crit.setFetchMode("expenseses.budgetaccounts", FetchMode.JOIN); crit.add(Restrictions.eq("project", proj)); crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); costs = crit.list(); } return costs; }
From source file:es.sm2.openppm.core.dao.ProjectCostsDAO.java
License:Open Source License
/** * Return Project direct costs/*from w w w .j av a2 s .c o m*/ * @param proj * @return */ @SuppressWarnings("unchecked") public List<Projectcosts> findDirectCostsByProject(Project proj) { List<Projectcosts> costs = null; if (proj != null) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("directcostses", FetchMode.JOIN); crit.setFetchMode("directcostses.budgetaccounts", FetchMode.JOIN); crit.add(Restrictions.eq("project", proj)); crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); costs = crit.list(); } return costs; }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * Cons project for initiating/* w ww. j ava2 s . c o m*/ * @param proj * @return */ public Project consInitiatingProject(Project proj) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("performingorg", FetchMode.JOIN); crit.setFetchMode("customer", FetchMode.JOIN); crit.setFetchMode(Project.GEOGRAPHY, FetchMode.JOIN); crit.setFetchMode(Project.CATEGORY, FetchMode.JOIN); crit.setFetchMode(Project.PROGRAM, FetchMode.JOIN); crit.setFetchMode("employeeByProjectManager", FetchMode.JOIN); crit.setFetchMode("employeeByProjectManager.contact", FetchMode.JOIN); crit.setFetchMode("employeeByInvestmentManager", FetchMode.JOIN); crit.setFetchMode("employeeByInvestmentManager.contact", FetchMode.JOIN); crit.setFetchMode("employeeByFunctionalManager", FetchMode.JOIN); crit.setFetchMode("employeeByFunctionalManager.contact", FetchMode.JOIN); crit.setFetchMode("employeeBySponsor", FetchMode.JOIN); crit.setFetchMode("employeeBySponsor.contact", FetchMode.JOIN); crit.setFetchMode("stakeholders", FetchMode.JOIN); crit.setFetchMode(Project.STAGEGATE, FetchMode.JOIN); crit.setFetchMode(Project.CLASSIFICATIONLEVEL, FetchMode.JOIN); crit.setFetchMode(Project.WORKINGCOSTSES, FetchMode.JOIN); crit.setFetchMode(Project.WORKINGCOSTSES + "." + Workingcosts.CURRENCY, FetchMode.JOIN); crit.setFetchMode(Project.PROJECTASSOCIATIONSFORDEPENDENT, FetchMode.JOIN); crit.setFetchMode(Project.PROJECTASSOCIATIONSFORDEPENDENT + "." + Projectassociation.PROJECTBYLEAD, FetchMode.JOIN); crit.setFetchMode(Project.PROJECTASSOCIATIONSFORLEAD, FetchMode.JOIN); crit.setFetchMode(Project.PROJECTASSOCIATIONSFORLEAD + "." + Projectassociation.PROJECTBYDEPENDENT, FetchMode.JOIN); crit.add(Restrictions.eq("idProject", proj.getIdProject())); return (Project) crit.uniqueResult(); }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * Cons Project and extra info//from www.j a va 2s. c o m * @param proj * @param joins * @return */ public Project consProject(Project proj, List<String> joins) { Criteria crit = getSession().createCriteria(getPersistentClass()); if (ValidateUtil.isNotNull(joins)) { for (String join : joins) { crit.setFetchMode(join, FetchMode.JOIN); } } crit.add(Restrictions.eq("idProject", proj.getIdProject())); return (Project) crit.uniqueResult(); }
From source file:es.sm2.openppm.core.dao.SecurityDAO.java
License:Open Source License
/** * Return Security data of an Employee if login & password are validated * @param login/*w w w. j a va 2 s.c o m*/ * @return */ @SuppressWarnings("unchecked") public Security getByLogin(Security login) { Security security = null; Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("contact", FetchMode.JOIN); crit.setFetchMode("contact.employees", FetchMode.JOIN); crit.setFetchMode("contact.employees.resourceprofiles", FetchMode.JOIN); crit.add(Restrictions.eq("login", login.getLogin())); List<Security> list = crit.list(); if (list != null && !list.isEmpty()) { security = list.get(0); } return security; }
From source file:es.sm2.openppm.core.dao.SecurityDAO.java
License:Open Source License
/** * Return Username in use//from w w w .jav a2 s . com * @param login * @return */ @SuppressWarnings("unchecked") public Security getByUserName(Security login) { Security security = null; Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("contact", FetchMode.JOIN); crit.setFetchMode("contact.employees", FetchMode.JOIN); crit.setFetchMode("contact.employees.resourceprofiles", FetchMode.JOIN); crit.add(Restrictions.eq("login", login.getLogin())); List<Security> list = crit.list(); if (list != null && !list.isEmpty()) { security = list.get(0); } return security; }
From source file:es.sm2.openppm.core.dao.SecurityDAO.java
License:Open Source License
/** * Return data of logged Contact//from w w w.j a v a2 s .com * @param userLogged * @return */ @SuppressWarnings("unchecked") public Contact getContactLogger(String userLogged) { Contact cont = null; Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("contact", FetchMode.JOIN); crit.setFetchMode("contact.employees", FetchMode.JOIN); crit.setFetchMode("contact.employees.resourceprofiles", FetchMode.JOIN); crit.add(Restrictions.eq("login", userLogged)); List<Security> list = crit.list(); if (list != null && !list.isEmpty()) { cont = list.get(0).getContact(); } return cont; }
From source file:es.sm2.openppm.core.dao.SkillsemployeeDAO.java
License:Open Source License
/** * //from w ww .j a v a2 s .c o m * @param employee * @return */ @SuppressWarnings("unchecked") public List<Skillsemployee> findByEmployee(Employee employee) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode(Skillsemployee.SKILL, FetchMode.JOIN); crit.add(Restrictions.eq(Skillsemployee.EMPLOYEE, employee)); return crit.list(); }