Example usage for org.hibernate Criteria uniqueResult

List of usage examples for org.hibernate Criteria uniqueResult

Introduction

In this page you can find the example usage for org.hibernate Criteria uniqueResult.

Prototype

public Object uniqueResult() throws HibernateException;

Source Link

Document

Convenience method to return a single instance that matches the query, or null if the query returns no results.

Usage

From source file:br.com.arsmachina.authentication.dao.hibernate.PermissionDAOImpl.java

License:Apache License

/**
 * @see br.com.arsmachina.authentication.dao.PermissionDAO#findByName(java.lang.String)
 *//* ww w. j  a v  a2s  . c  o  m*/
public Permission findByName(String name) {

    final Criteria criteria = createCriteria();
    criteria.add(Restrictions.eq("name", name));

    return (Permission) criteria.uniqueResult();

}

From source file:br.com.arsmachina.authentication.dao.hibernate.PermissionGroupDAOImpl.java

License:Apache License

/**
 * @see br.com.arsmachina.authentication.dao.PermissionGroupDAO#findByName(java.lang.String)
 *///from www . ja  v  a2  s .co m
public PermissionGroup findByName(String name) {

    final Criteria criteria = createCriteria();
    criteria.add(Restrictions.eq("name", name));

    return (PermissionGroup) criteria.uniqueResult();

}

From source file:br.com.arsmachina.dao.hibernate.ReadableDAOImpl.java

License:Apache License

/**
 * @see br.com.arsmachina.dao.ReadableDAO#countAll()
 *//* w ww . j av  a 2s.c o  m*/
public int countAll() {

    final Criteria criteria = createCriteria();

    criteria.setProjection(Projections.rowCount());

    return (Integer) criteria.uniqueResult();

}

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

public int quantidadeFiltrados(FiltroCliente filtro) {
    Criteria criteria = criarCriteriaParaFiltro(filtro);

    criteria.setProjection(Projections.rowCount());

    return ((Number) criteria.uniqueResult()).intValue();
}

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

public Cliente porMci(String mci) {
    Criteria criteria = criarCriteria();
    criteria.add(Restrictions.ilike("mci", mci));

    return (Cliente) criteria.uniqueResult();
}

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.Funcionarios.java

public Funcionario porChave(String chave) {
    Criteria criteria = criarCriteria();

    criteria.add(Restrictions.like("chave", chave));

    return (Funcionario) 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.bb.intranet.supermt.governo.sbg.repository.BBNoMunicipioRepositorio.java

public BbNoMunicipio porCodigoIBGE(String codigoIBGE) {
    Criteria criteria = criarCriteria();
    criteria.add(Restrictions.eq("codigoIBGE", codigoIBGE));
    return (BbNoMunicipio) criteria.uniqueResult();
}

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

public ContratacoesFCO porCodigoIBGE(String codigoIBGE) {
    Criteria criteria = criarCriteria();
    criteria.add(Restrictions.eq("codigoIBGE", codigoIBGE));

    return (ContratacoesFCO) criteria.uniqueResult();
}