// 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; }
private EntityManager getEntityManager() { return Banco.getInstance().getEntityManager(); }