Example usage for org.hibernate.criterion Restrictions ilike

List of usage examples for org.hibernate.criterion Restrictions ilike

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions ilike.

Prototype

public static Criterion ilike(String propertyName, String value, MatchMode matchMode) 

Source Link

Document

A case-insensitive "like" (similar to Postgres ilike operator) using the provided match mode

Usage

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<ConsentFile> searchConsentFile(ConsentFile consentFile)
        throws EntityNotFoundException, ArkSystemException {
    Criteria criteria = getSession().createCriteria(ConsentFile.class);
    if (consentFile != null) {

        if (consentFile.getId() != null) {
            criteria.add(Restrictions.eq("id", consentFile.getId()));
        }//from  www  .j a v  a2 s .  c  om

        if (consentFile.getConsent() != null) {
            criteria.add(Restrictions.eq("consent", consentFile.getConsent()));
        }

        if (consentFile.getFilename() != null) {
            criteria.add(Restrictions.ilike("filename", consentFile.getFilename(), MatchMode.ANYWHERE));
        }
    }
    criteria.addOrder(Order.desc("id"));

    @SuppressWarnings("unchecked")
    List<ConsentFile> list = criteria.list();
    return list;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<SubjectFile> searchSubjectFile(SubjectFile subjectFile)
        throws EntityNotFoundException, ArkSystemException {
    Criteria criteria = getSession().createCriteria(SubjectFile.class);
    if (subjectFile != null) {

        if (subjectFile.getId() != null) {
            criteria.add(Restrictions.eq("id", subjectFile.getId()));
        }//  w  ww .j  av a  2 s. c  o m

        if (subjectFile.getLinkSubjectStudy() != null) {
            criteria.add(Restrictions.eq("linkSubjectStudy", subjectFile.getLinkSubjectStudy()));
        }

        if (subjectFile.getStudyComp() != null) {
            criteria.add(Restrictions.eq("studyComp", subjectFile.getStudyComp()));
        }

        if (subjectFile.getFilename() != null) {
            criteria.add(Restrictions.ilike("filename", subjectFile.getFilename(), MatchMode.ANYWHERE));
        }
    }
    criteria.addOrder(Order.desc("id"));

    @SuppressWarnings("unchecked")
    List<SubjectFile> list = criteria.list();
    return list;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

/**
 * General Address search.//from ww w . ja  v a  2  s  .c om
 * @param personId
 * @param address
 * @return
 */
private Criteria buildGeneralAddressCriteria(Long personId, Address address) {
    Criteria criteria = getSession().createCriteria(Address.class);
    if (personId != null) {
        criteria.add(Restrictions.eq(Constants.PERSON_PERSON_ID, personId));
    }

    if (address != null) {
        // Add criteria for address
        if (address.getStreetAddress() != null) {
            criteria.add(Restrictions.ilike(Constants.STREET_ADDRESS, address.getStreetAddress(),
                    MatchMode.ANYWHERE));
        }

        if (address.getCountry() != null) {
            criteria.add(Restrictions.eq(Constants.COUNTRY_NAME, address.getCountry()));
        }

        if (address.getPostCode() != null) {
            criteria.add(Restrictions.eq(Constants.POST_CODE, address.getPostCode()));
        }

        if (address.getCity() != null) {
            criteria.add(Restrictions.ilike(Constants.CITY, address.getCity()));
        }

        if (address.getState() != null) {
            criteria.add(Restrictions.eq(Constants.STATE_NAME, address.getState()));
        }

        if (address.getAddressType() != null) {
            criteria.add(Restrictions.eq(Constants.ADDRESS_TYPE, address.getAddressType()));
        }
    }
    return criteria;
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public List<StudyCalendar> searchStudyCalenderList(StudyCalendar studyCalendar) {
    List<StudyCalendar> list = new ArrayList<StudyCalendar>();
    Criteria criteria = getSession().createCriteria(StudyCalendar.class);

    criteria.add(Restrictions.eq("study", studyCalendar.getStudy()));

    if (studyCalendar.getName() != null) {
        criteria.add(Restrictions.ilike("name", studyCalendar.getName(), MatchMode.ANYWHERE));
    }//from   ww w  .  ja  v  a 2  s  .  c o m

    if (studyCalendar.getStartDate() != null) {
        criteria.add(Restrictions.ge("startDate", studyCalendar.getStartDate()));
    }

    if (studyCalendar.getEndDate() != null) {
        criteria.add(Restrictions.le("endDate", studyCalendar.getEndDate()));
    }

    criteria.setFetchMode("studyComp", FetchMode.JOIN);

    list = criteria.list();

    return list;
}

From source file:br.com.ateliens.repository.ClientesFiltrados.java

private Criteria criarCriteriaParaFiltro(FiltroCliente filtro) {
    Session session = manager.unwrap(Session.class);
    Criteria criteria = session.createCriteria(Cliente.class);

    if (StringUtils.isNotEmpty(filtro.getNome())) {
        criteria.add(Restrictions.ilike("nome", filtro.getNome(), MatchMode.ANYWHERE));
    }/*  w  w w.  jav a2 s  . co  m*/
    return criteria;
}

From source file:br.com.bb.intranet.supermt.governo.repository.Estagios.java

public Estagio porValor(String valor) {
    Criteria criteria = criarCriteria();

    criteria.add(Restrictions.ilike("valor", valor, MatchMode.ANYWHERE));

    return (Estagio) criteria.uniqueResult();
}

From source file:br.com.bb.intranet.supermt.governo.repository.Produtos.java

public Produto porNome(String nome) {
    Criteria criteria = criarCriteria();

    criteria.add(Restrictions.ilike("nome", nome, MatchMode.ANYWHERE));

    return (Produto) criteria.uniqueResult();
}

From source file:br.com.gerenciapessoal.repository.Bancos.java

public List<Banco> filtrados(BancoFilter filter) {
    Session session = manager.unwrap(Session.class);
    Criteria criteria = session.createCriteria(Banco.class);

    if (StringUtils.isNotBlank(filter.getNumBanco())) {
        criteria.add(Restrictions.eq("numBanco", filter.getNumBanco()));
    }/*from ww  w  . j  av  a  2 s .  com*/

    if (StringUtils.isNotBlank(filter.getNome())) {
        criteria.add(Restrictions.ilike("nome", filter.getNome(), MatchMode.ANYWHERE));
    }

    if (StringUtils.isNotBlank(filter.getUf())) {
        criteria.add(Restrictions.ilike("uf", filter.getUf(), MatchMode.ANYWHERE));
    }

    if (StringUtils.isNotBlank(filter.getEstado())) {
        criteria.add(Restrictions.ilike("estado", filter.getEstado(), MatchMode.ANYWHERE));
    }

    if (StringUtils.isNotBlank(filter.getEndereco())) {
        criteria.add(Restrictions.ilike("endereco", filter.getEndereco(), MatchMode.ANYWHERE));
    }

    return criteria.addOrder(Order.asc("numBanco")).list();
}

From source file:br.com.gerenciapessoal.repository.Usuarios.java

@SuppressWarnings("unchecked")
public List<Usuario> filtrados(UsuarioFilter filtro) {
    Session session = manager.unwrap(Session.class);
    Criteria criteria = session.createCriteria(Usuario.class);

    if (StringUtils.isNotBlank(filtro.getNome())) {
        criteria.add(Restrictions.ilike("nome", filtro.getNome(), MatchMode.ANYWHERE));
    }//from  w  w w  .j  a  v a 2 s .  c  o  m

    if (StringUtils.isNotBlank(filtro.getEmail())) {
        criteria.add(Restrictions.ilike("email", filtro.getEmail(), MatchMode.ANYWHERE));
    }

    return criteria.addOrder(Order.asc("nome")).list();
}

From source file:br.com.hedo.aula4.PessoaDAO.java

public List<Pessoa> getByName(String name) {
    Session session = this.em.unwrap(Session.class);
    Criteria criteria = session.createCriteria(Pessoa.class);
    criteria.add(Restrictions.ilike("NOME", name, MatchMode.ANYWHERE));

    return criteria.list();
}