Hi,
i have a problem with my model. I have 2 database tables: projects and persons. They have a many to many relationship. My model looks like this:
In class Project i save a list of Persons in this Project:
private List<Person> persons;
other properties like name, description, etc ...
In class ProjectsModel i save the list of all Projects:
private List<Project> projects = new ArrayList<Project>();
private void readProjects() {
Query query = em.createQuery("select p from Project p");
projects = query.getResultList();
}
In class PersonsModel i save the list of all Persons:
private List<Project> persons = new ArrayList<Person>();
private void readPersons() {
Query query = em.createQuery("select p from Person p");
this.persons = query.getResultList();
}
And a Person class of course with properties of a person.
Cause of the queries i now have 2 different models. Changing a property of a Person from the PersonsModel instance doesn't change the persons property in a personslist in a project. But how can i solve this?