Pessoal boa tarde estou querendo utilizar a list do hibernate para fazer um select dos dados do banco e colocar em um dataTable mas está ocorrendo um erro na query do select.
Metodo na classe ReembolsoMB
identar public List <TbReembolso> verReembolso(){
Query query= query("select * TbReembolso");
List<TbReembolso> lista= query.list();
return lista;
}
MEtodos do TbReembolsoJpaController
identar public TbReembolsoJpaController(UserTransaction utx, EntityManagerFactory emf) {
this.utx = utx;
this.emf = emf;
}
private UserTransaction utx = null;
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(TbReembolso tbReembolso) throws PreexistingEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
em.persist(tbReembolso);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
if (findTbReembolso(tbReembolso.getReId()) != null) {
throw new PreexistingEntityException("TbReembolso " + tbReembolso + " already exists.", ex);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(TbReembolso tbReembolso) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
tbReembolso = em.merge(tbReembolso);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tbReembolso.getReId();
if (findTbReembolso(id) == null) {
throw new NonexistentEntityException("The tbReembolso with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Integer id) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
TbReembolso tbReembolso;
try {
tbReembolso = em.getReference(TbReembolso.class, id);
tbReembolso.getReId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tbReembolso with id " + id + " no longer exists.", enfe);
}
em.remove(tbReembolso);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public List<TbReembolso> findTbReembolsoEntities() {
return findTbReembolsoEntities(true, -1, -1);
}
public List<TbReembolso> findTbReembolsoEntities(int maxResults, int firstResult) {
return findTbReembolsoEntities(false, maxResults, firstResult);
}
private List<TbReembolso> findTbReembolsoEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TbReembolso.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public TbReembolso findTbReembolso(Integer id) {
EntityManager em = getEntityManager();
try {
return em.find(TbReembolso.class, id);
} finally {
em.close();
}
}
public int getTbReembolsoCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TbReembolso> rt = cq.from(TbReembolso.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}