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.ChangeControlDAO.java
License:Open Source License
@Deprecated public List<Changecontrol> findByProject(Project proj) { List<Changecontrol> list = null; if (proj != null) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY) .add(Restrictions.eq(Changecontrol.PROJECT, proj)); // Joins/*from ww w .j ava 2s .co m*/ crit.setFetchMode(Changecontrol.CHANGETYPE, FetchMode.JOIN); crit.setFetchMode(Changecontrol.CHANGEREQUESTWBSNODES, FetchMode.JOIN); // Order crit.addOrder(Order.asc(Changecontrol.CHANGEDATE)); list = crit.list(); } return list; }
From source file:es.sm2.openppm.core.dao.ChangeControlDAO.java
License:Open Source License
/** * Find by Id and return data//from w w w .java 2s . co m * @param change * @return */ public Changecontrol findByIdWithData(Changecontrol change) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("changetype", FetchMode.JOIN); crit.setFetchMode("wbsnode", FetchMode.JOIN); crit.add(Restrictions.eq("idChange", change.getIdChange())); return (Changecontrol) crit.uniqueResult(); }
From source file:es.sm2.openppm.core.dao.ChangeControlDAO.java
License:Open Source License
/** * Find change controls//from w w w . java 2 s . c o m * * @param search * @return */ public List<Changecontrol> find(ChangeControlSearch search) { List<Changecontrol> list = null; if (search.getIdProject() != null) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY) .add(Restrictions.eq(Changecontrol.PROJECT, new Project(search.getIdProject()))); // Joins crit.setFetchMode(Changecontrol.CHANGETYPE, FetchMode.JOIN); crit.setFetchMode(Changecontrol.CHANGEREQUESTWBSNODES, FetchMode.JOIN); // Filter by resolution if (search.getResolution() != null) { crit.add(Restrictions.eq(Changecontrol.RESOLUTION, search.getResolution())); } // Order crit.addOrder(Order.asc(Changecontrol.CHANGEDATE)); list = crit.list(); } return list; }
From source file:es.sm2.openppm.core.dao.ChargescostsDAO.java
License:Open Source License
/** * Cons Charge Costs by project and type * @param proj/*from w ww.j a v a2 s . c o m*/ * @param type * @return */ @SuppressWarnings("unchecked") public List<Chargescosts> consChargescostsByProject(Project proj, int type) { Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Chargescosts.PROJECT, proj)) .add(Restrictions.eq(Chargescosts.IDCHARGETYPE, type)) .setFetchMode(Chargescosts.CURRENCY, FetchMode.JOIN); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ContactDAO.java
License:Open Source License
/** * Return contact with company/*from www. j av a2 s . c o m*/ * @param contact * @return */ public Contact findByIdContact(Contact contact) { Contact cont = null; if (contact.getIdContact() != null) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("company", FetchMode.JOIN); crit.add(Restrictions.eq("idContact", contact.getIdContact())); cont = (Contact) crit.uniqueResult(); } return cont; }
From source file:es.sm2.openppm.core.dao.CustomerDAO.java
License:Open Source License
/** * Find customer by company//from w w w . j a v a 2 s . co m * @param company * @return */ @SuppressWarnings("unchecked") public List<Customer> findByCompany(Company company) { Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Customer.COMPANY, company)) .setFetchMode(Customer.CUSTOMERTYPE, FetchMode.JOIN); return crit.list(); }
From source file:es.sm2.openppm.core.dao.DataTableDAO.java
License:Open Source License
@SuppressWarnings({ "rawtypes" }) public List findByFiltro(FiltroTabla filtro, Class tipo, ArrayList<String> joins) throws ParseException { Criteria crit = getSession().createCriteria(tipo).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .setFirstResult(filtro.getDisplayStart()).setMaxResults(filtro.getDisplayLength()); for (DatoColumna order : filtro.getOrden()) { crit.addOrder((order.getValor().equals("asc") ? Order.asc(order.getNombre()) : Order.desc(order.getNombre()))); }/* w ww.ja v a2 s . c om*/ applyFilters(crit, filtro.getFiltro()); if (joins != null) { for (String join : joins) { crit.setFetchMode(join, FetchMode.JOIN); } } return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
@SuppressWarnings({ "rawtypes", "unchecked" }) public List<Employee> searchByExample(Employee exampleInstance, Class... joins) { Criteria crit = getSession().createCriteria(getPersistentClass()); if (exampleInstance.getPerformingorg() != null) { crit.add(Restrictions.eq("performingorg.idPerfOrg", exampleInstance.getPerformingorg().getIdPerfOrg())); }//from w w w .ja va 2 s.co m if (exampleInstance.getResourceprofiles() != null) { crit.add(Restrictions.eq("resourceprofiles.idProfile", exampleInstance.getResourceprofiles().getIdProfile())); } crit.setFetchMode("contact", FetchMode.JOIN); for (Class c : joins) { if (c.equals(Employee.class)) { crit.setFetchMode("employee", FetchMode.JOIN); crit.setFetchMode("employee.contact", FetchMode.JOIN); } else if (c.equals(Performingorg.class)) { crit.setFetchMode("performingorg", FetchMode.JOIN); } else if (c.equals(Resourceprofiles.class)) { crit.setFetchMode("resourceprofiles", FetchMode.JOIN); } } return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Find by id with Contact//from w ww . j a v a 2 s. co m * @param emp * @return */ public Employee findByIdWithContact(Employee emp) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode("contact", FetchMode.JOIN); crit.setFetchMode("contact.company", FetchMode.JOIN); crit.add(Restrictions.eq("idEmployee", emp.getIdEmployee())); return (Employee) crit.uniqueResult(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Return employee with data//ww w . ja va 2 s .c om * @param employee * @return */ public Employee findByIdEmployee(Employee employee) { Employee empl = null; if (employee.getIdEmployee() != null) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setFetchMode(Employee.CONTACT, FetchMode.JOIN); crit.setFetchMode(Employee.CONTACT + "." + Contact.COMPANY, FetchMode.JOIN); crit.setFetchMode(Employee.PERFORMINGORG, FetchMode.JOIN); crit.setFetchMode(Employee.RESOURCEPROFILES, FetchMode.JOIN); crit.add(Restrictions.eq("idEmployee", employee.getIdEmployee())); empl = (Employee) crit.uniqueResult(); } return empl; }