Here's basically what we have in our template:

Set<T> toRemove = new HashSet<T>(getX());
for (T obj : list) {
    if (!toRemove.remove(obj)) {
        addX(obj);
    }
}
for (T obj : toRemove) {
    removeX(obj);
}

Also, it may be better to put all that logic in CayanneDataObject and have
the template just call setToManyRelationship($rel.Name, collection).

- David


On Thu, Dec 18, 2014 at 1:58 PM, Johannes <jotpe....@gmail.com> wrote:
>
> Hello,
>
> following the conversation from
>
> http://mail-archives.apache.org/mod_mbox/cayenne-user/201412.mbox/%3C548BDF97.1040104%40gmail.com%3E
> there seems to be a common need for having a new method next to
> addXXX, removeXXX a setXXXs in generated classes from CayenneModeler.
>
> I created a first draft
>
> https://github.com/jotpe/cayenne/commit/6627c09936285c7650d69f44a95ba2f4b118f2b6
>
> Would anybody be so nice to review it? I'm not sure if these lines can
> run in every environment without trouble. What about tests?
>
> Best regards Johannes
>
>

Reply via email to