示例#1
0
  // consultar por idPolicial
  public List<Alteracao> consultarPorIdPolicial(Integer id) {
    CriteriaBuilder builder = Banco.getInstance().getEntityManager().getCriteriaBuilder();

    CriteriaQuery<Alteracao> query = builder.createQuery(Alteracao.class);
    Root<Alteracao> root = query.from(Alteracao.class);
    Predicate pred = builder.equal(root.get("idpolicial"), id);

    query.select(root);
    query.where(pred);

    TypedQuery<Alteracao> tpQuery = Banco.getInstance().getEntityManager().createQuery(query);
    List<Alteracao> list = tpQuery.getResultList();
    return list;
  }
示例#2
0
 private EntityManager getEntityManager() {
   return Banco.getInstance().getEntityManager();
 }