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:co.com.codesoftware.logica.receta.RecetaLogica.java

/**
 * funcion que obtiene las recetas por codigo
 *
 * @param codigo/*  ww w .j  a  v  a  2 s. c  o  m*/
 * @param sede
 * @return
 */
public PrecioRecetaEntity getRecetaXCodigo(String codigo, Integer sede) {
    PrecioRecetaEntity rta = new PrecioRecetaEntity();
    try {
        initOperation();
        rta = (PrecioRecetaEntity) sesion.createCriteria(PrecioRecetaEntity.class).createAlias("receta", "rec")
                .add(Restrictions.eq("rec.codigo", codigo)).add(Restrictions.eq("idSede", sede))
                .add(Restrictions.eq("estado", "A")).setFetchMode("receta", FetchMode.JOIN).uniqueResult();

    } catch (Exception e) {
        e.printStackTrace();
    }
    return rta;
}

From source file:co.com.codesoftware.logica.receta.RecetaLogica.java

/**
 * funcion que consulta las recetas por criterio
 * @param sede//from   www. ja  v a 2s .  c  o m
 * @param criterio
 * @return 
 */
public List<PrecioRecetaEntity> getRecetasXCriterio(Integer sede, String criterio) {
    List<PrecioRecetaEntity> receta = null;
    try {
        initOperation();
        receta = sesion.createCriteria(PrecioRecetaEntity.class).createAlias("receta", "rec")
                .add(Restrictions.like("rec.nombre", criterio, MatchMode.ANYWHERE).ignoreCase())
                .add(Restrictions.eq("estado", "A")).add(Restrictions.eq("idSede", sede))
                .setFetchMode("receta", FetchMode.JOIN).list();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return receta;
}

From source file:co.utb.softeng.contactsapp.dao.impl.CitaDAOImpl.java

@Override
public List<Cita> getAllCitas(boolean includeContacts) {
    Criteria crit = getSession().createCriteria(Cita.class);
    if (includeContacts) {
        crit = crit.setFetchMode("contacts", FetchMode.JOIN);
    }/*  w  w w  .  ja va 2 s. c  o m*/
    return crit.list();
}

From source file:co.utb.softeng.contactsapp.dao.impl.CitaDAOImpl.java

@Override
public Cita getById(Long id) {
    return (Cita) getSession().createCriteria(Cita.class).add(Restrictions.idEq(id))
            .setFetchMode("contacts", FetchMode.JOIN).uniqueResult();
}

From source file:co.utb.softeng.contactsapp.dao.impl.CitaDAOImpl.java

@Override
public List<Cita> getByName(String name) {
    return getSession().createCriteria(Cita.class).add(Restrictions.ilike("name", name))
            .setFetchMode("contacts", FetchMode.JOIN).list();
}

From source file:co.utb.softeng.contactsapp.dao.impl.CitaDAOImpl.java

@Override
public List<Cita> getByContactName(String contactName) {

    DetachedCriteria subQuery = DetachedCriteria.forClass(Contact.class).createCriteria("citas")
            .add(Restrictions.ilike("name", contactName, MatchMode.ANYWHERE)).setProjection(Projections.id());

    Criteria mainCriteria = getSession().createCriteria(Cita.class).add(Subqueries.propertyIn("id", subQuery))
            .setFetchMode("contacts", FetchMode.JOIN);

    return mainCriteria.list();
}

From source file:co.utb.softeng.contactsapp.dao.impl.ContactDAOImpl.java

public Contact getById(Long id) {

    return (Contact) getSession().createCriteria(Contact.class).add(Restrictions.idEq(id))
            .setFetchMode("citas", FetchMode.JOIN).uniqueResult();
}

From source file:co.utb.softeng.contactsapp.dao.impl.ContactDAOImpl.java

public List<Contact> getByName(String name) {
    return getSession().createCriteria(Contact.class).add(Restrictions.ilike("name", name, MatchMode.ANYWHERE))
            .setFetchMode("citas", FetchMode.JOIN).list();
}

From source file:co.utb.softeng.contactsapp.dao.impl.ContactDAOImpl.java

public List<Contact> getAllContacts(boolean includeCitas) {
    Criteria crit = getSession().createCriteria(Contact.class);
    if (includeCitas)
        crit = crit.setFetchMode("citas", FetchMode.JOIN);
    return crit.list();
}

From source file:co.utb.softeng.contactsapp.dao.impl.ContactDAOImpl.java

@Override
public List<Contact> getByCitaName(String citaName) {
    Criterion crit1 = Restrictions.ilike("asunto", citaName, MatchMode.ANYWHERE);
    Criterion crit2 = Restrictions.ilike("lugar", citaName, MatchMode.ANYWHERE);

    DetachedCriteria subQuery = DetachedCriteria.forClass(Contact.class).createCriteria("citas")
            .add(Restrictions.or(crit1, crit2)).setProjection(Projections.id());

    Criteria mainCriteria = getSession().createCriteria(Contact.class)
            .add(Subqueries.propertyIn("id", subQuery)).setFetchMode("citas", FetchMode.JOIN);

    return mainCriteria.list();
}