Hello, I moved the method to CayenneDataObject. I hope the documentation is more meaningfull now.
The superclass.vm contains for every set-able relationship two method which calls the setter in CayenneDataObject. Two methods because a default value for deletion. Would be happy if anybody could review it again at https://github.com/jotpe/cayenne/commit/d7251014c9d5cb9396a83cd6e2f16e64af27e4b5 Regards Johannes Am 20.12.2014 um 01:01 schrieb Johannes: > Hi Michael, > > thank for this scenario. > > My intention is to create a simple setter. A List or Set as Parameter is > just a container for the complete amount of elements which should be set. > > The method works just on a copy of the List Parameter. When the input > parameter is a persistet ToManyList, it will be downgraded to none > persistent ArrayList. > > Calling A1.setB(C) should create > A1 ->> B1, B2, B5, B7 > >> Should it automatically try to reconcile all changes amongst all > objects in >> the object graph (removing objects from A1 and A2) > > No > >> Also, what should happen to B3? Should it be deleted or >> orphaned? > > I didn't thought yet about orphaned elements. Good point. > No doubt, the relationship to B3 has to be removed. Best would be to > take care about the element as required by the deletion rule. > > I guess, I should write the method documentation more clearly. > > Regards Johannes > > Am 19.12.2014 um 15:11 schrieb Michael Gentry: >> Hi Johannes, >> >> What you consider basic functionality can actually be not so basic. >> >> Consider this scenario of some objects: >> >> A1 ->> B1, B2, B3 >> A2 ->> B4, B5, B6, B7 >> >> Then you create a new collection: >> >> C = B1, B2, B5, B7 >> >> What then happens when you call: >> >> A1.setB(C) >> >> Should it automatically try to reconcile all changes amongst all objects in >> the object graph (removing objects from A1 and A2) or is this perhaps >> indicative of a programming error because you mixed two object relationship >> graphs together? Also, what should happen to B3? Should it be deleted or >> orphaned? >> >> The way Cayenne is currently set up, you have to manually do that, which is >> perhaps cumbersome, but more exacting. >> >> mrg >> >> >> On Fri, Dec 19, 2014 at 9:00 AM, Johannes <jotpe....@gmail.com> wrote: >>> >>> Good point, I thought reverse relationships are refreshed autimatically. >>> My expectation was based on the note "... from any kind of >>> relationship..." at http://cayenne.apache.org/docs/3.0/relationships.html >>> I will replace the methods! >>> >>> I think you are an advanced user, if you only use your own templates and >>> answer to dev mailinglist. But to offer such a BASIC functionality in >>> normal generated classes would be a nice service for new users. >>> >>> Thanks Johannes >>> >>> Am 18.12.2014 um 21:12 schrieb Mike Kienenberger: >>>> As I said before, I think you need to call >>>> removeToManyTarget("${rel.Name}", obj, true); instead of >>>> iterator.remove() and removeAll(), and then you need to call >>>> addToManyTarget() instead of addAll(). Otherwise, you are losing the >>>> reverse relationship changes. >>>> >>>> But the rest seems ok. >>>> >>>> I'm not saying that adding setList() to the default template is a good >>>> idea, though. I think having it in your custom template is good >>>> enough. >>>> >>>> I do everything with custom templates and rarely use the default >>>> cayenne templates. >>>> >>>> >>>> On Thu, Dec 18, 2014 at 2: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 >>>>> >>> >>> >> >
signature.asc
Description: OpenPGP digital signature