0
Guys, I have a question here at JPA. Today I have a method to search the Ufs by ID, as in the example below:
public Uf consulta(Integer id) {
EntityManager em = getEM();
Uf uf = new Uf();
try {
em.getTransaction().begin();
uf = em.find(Uf.class, id);
em.getTransaction().commit();
} catch (Exception e) {
em.getTransaction().rollback();
} finally {
em.close(); //fecha o EntityManager
}
return uf;
}
Do you have any way to pull all the bank records without having to go through one by one ? My idea is to present all the records in a table, but I don’t know if I need to consult one by one with find inside a for and add in the Array for example, or if there’s any way in jpa that brings everything to me without needing a go. Any hint will be useful.
It worked, thank you!
– Andre Hoffmann