Hi, I am a bit confused about ToManyList and if I have understood correctly how they work.
My Tables are as follows: PERSON (PK ID), BUILDING (PK ID), PERSON_BUILDING (PK PERSON_ID, BUILDING_ID). The Classes generated from this are: Person and Building. I have modelled it so that Person.getBuildings() would return a list of buildings that person has access to (going through PERSON_BUILDING via flattened relationships) and Building.getPersons() would get the persons allowed into that building. For me the simplest (and most natural) way of adding/removing access would be something like this: Person p = PersonService.getById(id); Building b = BuildingService.getById(id2); p.getBuildings().add(b); Person p2 = PersonService.getById(id3); List<Building> bs = BuildingService.getAllById(listOfIds); p2.getBuildings().removeAll(bs); (and then commit). For my simple test this seems to work. But when cayenne generates the domain classes it creates additional methods: Person.removeFromBuildings(Building b); Person.addToBuildings(Building b); and same for Buildings. This seems redundant if one can already do this by editing the list to me, so I was a bit confused. Furthermore I found a Mailinglist entry that said if one doesn't use the provider methods, reverse relationships are not removed. For me the reverse relationship of Person -> Building is Building -> Person, but this hinges on the same table entry in PERSON_BUILDING, so if I delete it, the reverse Relationship should be gone too, no? Also all examples in the docs and demos, use the generated methods, so I am unsure if I can use the ToManyList directly or if that will somehow break something later. Thanks, Friedrich
