I'm trying to code a jsp webpage showing users in the database. The page is working corretly.
For example it's possible to remove users from database by clicking a link on the page, but unfortunately the user is still shown on the next load of the page. After reloading the page the user is gone. I added a @Cacheable(false)
to the JPA class but nothing changed.
For a better understanding an example workflow:
- Admin clicks on Usermanagement (calling "showUserHandler" servlet)
- Page is loading with the first 10 users from database
- Admin deletes User ( by calling a handler(MVC)/servlet)
- Servlet deletes the user and calls the showUserHandler from point number 1
- Page is loading, showing 10 users, but the deleted user is still there
- Pressing F5 or "reload" and the user is gone
The user is removed like:
Users user = em.find(Users.class, request.getParameter("uId"));
if (user != null) {
em.getTransaction().begin();
em.remove(user);
em.getTransaction().commit();
em.close();
}
And loading the user:
EntityManager em = SessionUtil.createManager();
List<Users> usersList = em.createNamedQuery("Users.findAllOrdered", Users.class).setParameter("uId", Integer.parseInt(request.getParameter("lastID"))).setFirstResult(0).setMaxResults(10).getResultList();
Can someone tell me whats wrong ?