List of usage examples for org.hibernate FetchMode JOIN
FetchMode JOIN
To view the source code for org.hibernate FetchMode JOIN.
Click Source Link
From source file:es.sm2.openppm.core.dao.ProjectFollowupDAO.java
License:Open Source License
/** * Find follow ups for notify// w w w . j a va 2 s .co m * @return */ @SuppressWarnings("unchecked") public List<Projectfollowup> findForNotify() { Calendar actualDate = DateUtil.getCalendar(); Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.le(Projectfollowup.FOLLOWUPDATE, actualDate.getTime())) .add(Restrictions.isNull(Projectfollowup.GENERALFLAG)) .add(Restrictions.isNull(Projectfollowup.RISKFLAG)) .add(Restrictions.isNull(Projectfollowup.COSTFLAG)) .add(Restrictions.isNull(Projectfollowup.SCHEDULEFLAG)) .setFetchMode(Projectfollowup.PROJECT, FetchMode.JOIN) .setFetchMode(Projectfollowup.PROJECT + "." + Project.EMPLOYEEBYPROJECTMANAGER, FetchMode.JOIN) .setFetchMode( Projectfollowup.PROJECT + "." + Project.EMPLOYEEBYPROJECTMANAGER + "." + Employee.CONTACT, FetchMode.JOIN); Criteria crit2 = crit.createCriteria(Projectfollowup.PROJECT); crit2.add(Restrictions.eq(Project.STATUS, Constants.STATUS_CONTROL)); return crit.list(); }
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//from w w w .j a v a2 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 www . j a v a2 s.co m * @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 ww. jav a 2s . c om * @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.SettingDAO.java
License:Open Source License
/** * Find setting// w w w.j av a 2 s.c om * @param company * @param name * @return */ public Setting findSetting(Company company, String name) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setFetchMode(Setting.COMPANY, FetchMode.JOIN).add(Restrictions.eq(Setting.COMPANY, company)) .add(Restrictions.eq(Setting.NAME, name)); return (Setting) crit.uniqueResult(); }
From source file:es.sm2.openppm.core.dao.SkillsemployeeDAO.java
License:Open Source License
/** * /* ww w .j a va2 s.c om*/ * @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(); }
From source file:es.sm2.openppm.core.dao.StakeholderDAO.java
License:Open Source License
/** * Find stakeholder by project/*from w w w.j ava2 s.c om*/ * * @param proj * @param order * @return */ @SuppressWarnings("unchecked") public List<Stakeholder> findByProject(Project proj, Order... order) { // Add project to criteria Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Stakeholder.PROJECT, proj)).setFetchMode(Stakeholder.EMPLOYEE, FetchMode.JOIN) .setFetchMode(Stakeholder.EMPLOYEE + "." + Employee.CONTACT, FetchMode.JOIN); // Add orders for (Order o : order) { addOrder(crit, o.getProperty(), o.getTypeOrder()); } // Return result return crit.list(); }
From source file:es.sm2.openppm.core.dao.StakeholderDAO.java
License:Open Source License
/** * Find stakeholders by project and classification * /*from ww w . ja v a 2 s . c o m*/ * @param proj * @param order * @return */ @SuppressWarnings("unchecked") public List<Stakeholder> findByProjectAndClassification(Project proj, Stakeholderclassification classif, Order... order) { // Add classification and project to criteria Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Stakeholder.PROJECT, proj)) .add(Restrictions.eq(Stakeholder.STAKEHOLDERCLASSIFICATION, classif)) .setFetchMode(Stakeholder.EMPLOYEE, FetchMode.JOIN) .setFetchMode(Stakeholder.EMPLOYEE + "." + Employee.CONTACT, FetchMode.JOIN) .setFetchMode(Stakeholder.STAKEHOLDERCLASSIFICATION, FetchMode.JOIN); // Add orders for (Order o : order) { addOrder(crit, o.getProperty(), o.getTypeOrder()); } // Return results return crit.list(); }
From source file:es.sm2.openppm.core.dao.TeamMemberDAO.java
License:Open Source License
/** * Search Team Members by Project...// w ww .ja v a 2 s . co m * * @param project * @param since * @param until * @param showDisabled * @return */ public List<Teammember> consStaffinFtes(Project project, Date since, Date until, boolean showDisabled) { // Create query and restrictions Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.or(Restrictions.eq(Teammember.STATUS, Constants.RESOURCE_ASSIGNED), Restrictions.eq(Teammember.STATUS, Constants.RESOURCE_RELEASED))) .add(Restrictions.disjunction().add(Restrictions.between(Teammember.DATEIN, since, until)) .add(Restrictions.between(Teammember.DATEOUT, since, until)) .add(Restrictions.and(Restrictions.le(Teammember.DATEIN, since), Restrictions.ge(Teammember.DATEOUT, until)))); // Restriction project crit.createCriteria(Teammember.PROJECTACTIVITY).add(Restrictions.eq(Projectactivity.PROJECT, project)); if (!showDisabled) { // Exclude employees and contacts disabled crit.createCriteria(Teammember.EMPLOYEE, "em").add(Restrictions.ne(Employee.DISABLE, true)) .setFetchMode(Teammember.EMPLOYEE + "." + Employee.RESOURCEPROFILES, FetchMode.JOIN); crit.createCriteria("em." + Employee.CONTACT, "contact").add(Restrictions.ne(Contact.DISABLE, true)); } else { crit.setFetchMode(Teammember.EMPLOYEE, FetchMode.JOIN); crit.setFetchMode(Teammember.EMPLOYEE + "." + Employee.RESOURCEPROFILES, FetchMode.JOIN); crit.setFetchMode(Teammember.EMPLOYEE + "." + Employee.CONTACT, FetchMode.JOIN); // Create aliases for order crit.createAlias(Teammember.EMPLOYEE, "em").createAlias("em." + Employee.CONTACT, "contact"); } // Data needed crit.setFetchMode(Teammember.JOBCATEGORY, FetchMode.JOIN); // Order by name crit.addOrder(Order.asc("contact.fullName")); return crit.list(); }
From source file:es.sm2.openppm.core.dao.TeamMemberDAO.java
License:Open Source License
/** * Search Team Members by Project with actuals FTEs * // ww w. ja v a2 s . c o m * @param project * @param since * @param until * @return */ public List<Teammember> consStaffinActualsFtes(Project project, Date since, Date until) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.eq(Teammember.STATUS, Constants.RESOURCE_ASSIGNED)) .add(Restrictions.disjunction().add(Restrictions.between(Teammember.DATEIN, since, until)) .add(Restrictions.between(Teammember.DATEOUT, since, until)) .add(Restrictions.and(Restrictions.le(Teammember.DATEIN, since), Restrictions.ge(Teammember.DATEOUT, until)))); crit.createCriteria(Teammember.PROJECTACTIVITY).add(Restrictions.eq(Projectactivity.PROJECT, project)); Criteria timesheetsCrit = crit.createCriteria(Teammember.EMPLOYEE).createCriteria(Employee.TIMESHEETS) .add(Restrictions.eq(Timesheet.STATUS, Constants.TIMESTATUS_APP3)) .add(Restrictions.disjunction().add(Restrictions.between(Timesheet.INITDATE, since, until)) .add(Restrictions.between(Timesheet.ENDDATE, since, until)) .add(Restrictions.and(Restrictions.le(Timesheet.INITDATE, since), Restrictions.ge(Timesheet.ENDDATE, until)))); timesheetsCrit.createCriteria(Timesheet.PROJECTACTIVITY) .add(Restrictions.eq(Projectactivity.PROJECT, project)); crit.setFetchMode(Teammember.JOBCATEGORY, FetchMode.JOIN); crit.setFetchMode(Teammember.EMPLOYEE, FetchMode.JOIN); crit.setFetchMode(Teammember.EMPLOYEE + "." + Employee.CALENDARBASE, FetchMode.JOIN); return crit.list(); }