Example usage for org.hibernate FetchMode JOIN

List of usage examples for org.hibernate FetchMode JOIN

Introduction

In this page you can find the example usage for org.hibernate FetchMode JOIN.

Prototype

FetchMode JOIN

To view the source code for org.hibernate FetchMode JOIN.

Click Source Link

Document

Fetch using an outer join.

Usage

From source file:es.sm2.openppm.core.dao.ProgramDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Program> findByPO(Employee user) {

    Criteria crit = getSession().createCriteria(getPersistentClass()).addOrder(Order.asc(Program.PROGRAMNAME))
            .setFetchMode("employee", FetchMode.JOIN).setFetchMode("employee.contact", FetchMode.JOIN)
            .add(Restrictions.eq(Program.PERFORMINGORG, user.getPerformingorg()));

    return crit.list();
}

From source file:es.sm2.openppm.core.dao.ProgramDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Program> consByCompany(Company company, List<String> joins) {

    Criteria crit = getSession().createCriteria(getPersistentClass()).addOrder(Order.asc(Program.PROGRAMNAME));

    if (joins != null) {
        for (String join : joins) {
            crit.setFetchMode(join, FetchMode.JOIN);
        }// w w  w.java  2  s. c  o m
    }
    crit.createCriteria(Program.PERFORMINGORG).add(Restrictions.eq(Performingorg.COMPANY, company));

    return crit.list();
}

From source file:es.sm2.openppm.core.dao.ProgramDAO.java

License:Open Source License

/**
 * Search programs by filters/*w  w  w  .ja  v a2s  . c o  m*/
 * @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//  www  . j a v  a  2 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   ww  w. ja  va  2s  .c o  m*/
 * @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//ww  w .j  a  v  a  2  s  .c om
 * @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  w w  . j  a  v a 2 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 w w  w .  ja  va2 s . 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.ProjectFollowupDAO.java

License:Open Source License

/**
 * Return Project Followups//from   ww w . ja  v  a 2 s  . co m
 * @param proj
 * @return
 */
@SuppressWarnings("unchecked")
public List<Projectfollowup> findByProject(Project proj, String order) {
    List<Projectfollowup> followups = null;
    if (proj != null) {
        Criteria crit = getSession().createCriteria(getPersistentClass()).setFetchMode(Projectfollowup.PROJECT,
                FetchMode.JOIN);

        crit.add(Restrictions.eq("project.idProject", proj.getIdProject()));
        if (order.equals(Constants.ASCENDENT)) {
            crit.addOrder(Order.asc("followupDate"));
        } else if (order.equals(Constants.DESCENDENT)) {
            crit.addOrder(Order.desc("followupDate"));
        }

        followups = crit.list();
    }
    return followups;
}

From source file:es.sm2.openppm.core.dao.ProjectFollowupDAO.java

License:Open Source License

/**
 * Cons followup with project/* ww  w . j  a  va2 s  .co  m*/
 * @param projectfollowup
 * @return
 */
public Projectfollowup consFollowupWithProject(Projectfollowup projectfollowup) {

    Criteria crit = getSession().createCriteria(getPersistentClass())
            .setFetchMode(Projectfollowup.PROJECT, FetchMode.JOIN)
            .add(Restrictions.idEq(projectfollowup.getIdProjectFollowup()));

    return (Projectfollowup) crit.uniqueResult();
}