i have 2 tables with a ManyToMany relationship. Projects and Persons. I have 2 lists, one with projects and one with persons. In one list are all the persons from the person table in the other all the projects from the project table. Each Project has a list with all persons in it and each person a list with all projects that person is in. If i now delete a person the person gets deleted from the person table and from the "person_in_project" table in my database. The problem i have is that if i now re-read the tables:
Query query = em.createQuery("select p from Project p");
projects = query.getResultList();
Query query = em.createQuery("select p from Person p");
persons = query.getResultList();
the person that was deleted (and so doesn't exist anymore) is still in it's projects.
I found out that this doesn't happen if i disable the shared cache, but this can't be the answer. So what to do