Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A0DB1200BFF for ; Tue, 17 Jan 2017 16:08:02 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9F2CE160B46; Tue, 17 Jan 2017 15:08:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C3874160B43 for ; Tue, 17 Jan 2017 16:08:01 +0100 (CET) Received: (qmail 54026 invoked by uid 500); 17 Jan 2017 15:08:00 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 54014 invoked by uid 99); 17 Jan 2017 15:08:00 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jan 2017 15:08:00 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id ECC23180371 for ; Tue, 17 Jan 2017 15:07:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.48 X-Spam-Level: ** X-Spam-Status: No, score=2.48 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=masslight-net.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id W4z9h6qrWtdM for ; Tue, 17 Jan 2017 15:07:57 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 5710F5F576 for ; Tue, 17 Jan 2017 15:07:57 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id r126so204719183wmr.0 for ; Tue, 17 Jan 2017 07:07:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=masslight-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=5XBqPhL07UBzaX/+NgsBvab+zLMFM6PagS4A1A6i8Ms=; b=V4/HeiPm7nzZeKUy0AKeEtJOAqjDQm1kA75duFHlaAPtL+2I8LUSY7xnofIhvO6swl M69pzgKLsRn+aWtTEXgRtjJ82xeHx6hJ+WUc91/h3jvPfbUyrieRhhuFCXVcSzZjTLZm vtwsAcAupwbAXrZUrDTXh3eR8/Qg06vBWzlrhIBEgHuOzI5EPhKhFK7OqHW9icSGttMr Tge3lZg01jdX96a7ijHhaifG4fBcmTw0Y56aJemBPXkaenXxsc7NHLk4k9FPTQ1jKSnv FoRTivCiAVSePRy6sXSYDZk2oCAkCDmmZ3TcL9pYqbMBq+DZIpXuY5SR3tRzl6Nnyp9O 5fqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=5XBqPhL07UBzaX/+NgsBvab+zLMFM6PagS4A1A6i8Ms=; b=oudzyMaIecgHvkPwfNQdRJXFFJnvIQPG1J+EkLB0x4oFDptGBiVXj6foMUlW3bPkX2 O0EvqefZy5UfGAjwEuniFBDY2V/jD0+oRfSHsDiXHzpcQMGSpEZtGW+B55Pzd1iTvVsH 0Vgka7x0v5tYI/A01+aqXzAwWZVFTmoMk3MqYMH31aeFEP9MjaGt4w2Gsw6oNHInGKN/ +B1gYSqYxgunROyGO9qX0GabTxHcDZyD8afBvenrK+vWowEMa0r9Ged+B8ALCUN73ChB PeDA9m6FvMIV2OvbcuLyQEPM/f1c8gGHxMqlgPIwWxEz0op96n7ONVjgjk9wrf18K0no U0zw== X-Gm-Message-State: AIkVDXK2na/ENz8hBJNMCj9ipS+K67roeMXfdhBDjhEWtgm4xJR4O6CibH2Wg8lDWt/5G/n7FFkXquWloK/0Yg== X-Received: by 10.28.22.200 with SMTP id 191mr15794244wmw.132.1484665676248; Tue, 17 Jan 2017 07:07:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.185.68 with HTTP; Tue, 17 Jan 2017 07:07:35 -0800 (PST) In-Reply-To: References: <67c9aa19b3cd4fa99e0a521428ae1bc1@git.apache.org> <8970F5AF-F807-4427-8775-1D025137F807@objectstyle.org> <6A6409B8-A54C-461B-ADC3-7442917B3A9E@objectstyle.org> From: Michael Gentry Date: Tue, 17 Jan 2017 10:07:35 -0500 Message-ID: Subject: Re: Modeling annotations To: Cayenne Developers Content-Type: multipart/alternative; boundary=001a1146d90a3e589c05464baafd archived-at: Tue, 17 Jan 2017 15:08:02 -0000 --001a1146d90a3e589c05464baafd Content-Type: text/plain; charset=UTF-8 I don't think that will allow enough granularity or control. For example, there are certain fields we don't want exposed, etc. A custom template would apply the same annotation everywhere. That's why in the new CM I was adding annotation support on everything. On Tue, Jan 17, 2017 at 9:58 AM, Andrus Adamchik wrote: > I wonder if "regular" things like JAXB annotations can be generated via a > custom template? > > Andrus > > > On Jan 16, 2017, at 11:20 AM, Michael Gentry > wrote: > > > > My initial desire for annotation support was to allow for JAXB > annotations ( > > http://www.techferry.com/articles/jaxb-annotations.html), but of course > it > > could be used for other purposes. I'm not sure how much IDE refactoring > > would take place in this arena. I concede renaming "MyHandler" could be > > problematic, or at least surprising -- hopefully you'd notice the _ > > superclasses had unexpected changes. > > > > I really want to be able to specify annotations, but I'd also hate to > lose > > the generation gap pattern and "uglify" the subclasses (if they even > > existed at that point) with something like this: > > > > @MyA { > > handler = com.foo.MyHandler, > > types = {"a", "b", "c"}, > > name = "foo" > > } > > @Generated // By Cayenne - DO NOT EDIT > > @XmlElement // I intentionally put this annotation after @Generated to > > maybe cause problems... > > public String getNotes() { > > return (String)readProperty(NOTES_PROPERTY); > > } > > [repeat] > > > > You'd also need to "protect" NOTES_PROPERTY as well, all the relationship > > methods, etc. > > > > I can see it being quite difficult to merge without causing problems, > too. > > You'd also need to properly parse the method to find the end -- people > can > > have custom templates where more logic is added into the generated > methods, > > so you can't just skip to the next }. Also, how do you track renames? > If > > someone changed "notes" in CM to "note" and regenerated classes, would it > > create a new getter/setter for "note", delete "notes" and all annotations > > on it, losing the annotations you had intended for "notes" (which is now > > "note")? This would also be quite surprising for most users. > > > > Thanks, > > > > mrg > > > > > > On Sun, Jan 8, 2017 at 3:36 AM, Andrus Adamchik > > wrote: > > > >> [splitting annotations discussion in its own thread] > >> > >>> On Jan 8, 2017, at 10:40 AM, Andrus Adamchik > >> wrote: > >>> > >>>> On Jan 8, 2017, at 1:12 AM, Michael Gentry > wrote: > >>>> We had looked at overriding getters/setters for annotations, but we > >> didn't > >>>> want to do that 1000s of times, so we gave up. > >>>> I see value in the > >>>> superclass being able to have annotations along with JavaDocs for > >> various > >>>> attributes and relationships, plus the class itself. The superclass > is > >>>> essentially maintained outside of the IDE currently, anyway (you may > >> look > >>>> at the code, but you don't edit it), so I don't think it'll be too > bad. > >> > >>> But how does this save us work creating annotations? If you had to > >> override 1000's of methods, then you will have to create 1000's of > >> annotations in the Modeler as well to achieve the same effect. The only > way > >> to cut down on the number of (repeating) annotations is if they are are > all > >> applied to the same properties of different entities. Then they can be > >> moved to a separate interface (or a superclass common to all entities), > all > >> outside the Modeler and within the IDE. > >> > >> More on why annotations being on the IDE side is important ... > Annotations > >> do not have to be trivial. They may have a bunch of references to other > >> code. So taking them out of reach of the IDE refactoring is really > >> inconvenient. E.g.: > >> > >> @MyA { > >> handler = com.foo.MyHandler, > >> types = {"a", "b", "c"}, > >> name = "foo" > >> } > >> class MyClass {} > >> > >> So here if you say rename "MyHandler", you have a good chance of missing > >> it in the XML. We've seen this problem repeatedly with Listener classes > >> mapped in the Modeler, which led us to remove Listener functionality > from > >> the Modeler completely. This generally made me extremely wary of keeping > >> non-ORM pieces of code in the XML. > >> > >> So perhaps there's another solution for annotations? Such as replacing > the > >> "generation gap" pattern in the future versions with smarter "merging" > code > >> generators (e.g. using @javax.annotation.Generated to tell the code > >> generated by us from the code created by the user). > >> > >> Andrus > >> > >> > > --001a1146d90a3e589c05464baafd--