Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4FF5818DA9 for ; Fri, 24 Jul 2015 17:10:40 +0000 (UTC) Received: (qmail 58127 invoked by uid 500); 24 Jul 2015 17:10:24 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 58103 invoked by uid 500); 24 Jul 2015 17:10:24 -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 58088 invoked by uid 99); 24 Jul 2015 17:10:24 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jul 2015 17:10:24 +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 B6EE818E957 for ; Fri, 24 Jul 2015 17:10:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id DAGnB-oMh6Bl for ; Fri, 24 Jul 2015 17:10:09 +0000 (UTC) Received: from mail-03.1984.is (mail-03.1984.is [93.95.224.70]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id BF5C0215E2 for ; Fri, 24 Jul 2015 17:10:08 +0000 (UTC) Received: from localhost by mail-03.1984.is with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.84) (envelope-from ) id 1ZIgU2-00054J-Jg for dev@cayenne.apache.org; Fri, 24 Jul 2015 17:10:06 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: get-prefix in DataObjects From: Hugi Thordarson In-Reply-To: Date: Fri, 24 Jul 2015 17:10:01 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <480043BF-9198-4769-ADF0-D44472D05922@karlmenn.is> References: <19646BEB-0A63-4103-8301-5036FAFD7B92@karlmenn.is> <61E99BB3-3079-45B0-B454-C58F4C16A6C2@objectstyle.org> <725EA291-D5EF-40A6-8680-EAC7BC07E62E@karlmenn.is> To: dev@cayenne.apache.org X-Mailer: Apple Mail (2.2102) Yes, that would be optimal and I attempted to make it a static inner = class for precisely that reason, but it didn=E2=80=99t work. The = BeanInfo class must reside within the same package as the class it=E2=80=99= s supplementing and be called [ClassName]BeanInfo. The best documentation I found on this is here:=20 = http://www-01.ibm.com/support/knowledgecenter/SSZND2_6.0.0/org.eclipse.ve.= doc/topics/cve_beaninfo.html It mentions you can specify a search path for BeanInfo classes using = Introspector.setSearchPath() but I wasn=E2=80=99t able to get it to work = with inner classes. Cheers, - hugi > On 24. j=C3=BAl. 2015, at 17:01, John Huss = wrote: >=20 > It would be pretty easy to generate it as a static inner class using = the > entity template, then all the code is generated. Do the BeanInfo = classes > have to be registered somewhere? >=20 > On Fri, Jul 24, 2015 at 11:32 AM Hugi Thordarson = wrote: >=20 >> Thanks John, implementing a BeanInfo class for eaach entity = specifying >> method names actually works fine! >> The BeanInfo class can be associated with the superclass and placed = in >> it=E2=80=99s package so it=E2=80=99s mostly out of the way, here=E2=80=99= s an example >> implementation for an entity called =E2=80=9CProduct=E2=80=9D = containing a single property >> called =E2=80=9Cname=E2=80=9D. >>=20 >> https://gist.github.com/hugith/d1958e9ead2d3c1a390d >>=20 >> Something of a hassle to have to do this for the entire object graph, >> though. >>=20 >> Cheers, >> - hugi >>=20 >>=20 >>=20 >>> On 24. j=C3=BAl. 2015, at 14:15, John Huss = wrote: >>>=20 >>> In theory the bean spec allows you to specify a BeanInfo object that = can >>> allow you to use different naming conventions, but in practice most >>> libraries cut corners and just assume "get" and "set". I'm not sure = if >> it >>> works with Cayenne's Property and PropertyUtils however. For myself = I >>> found it easier to just add the "get" prefix. >>>=20 >>> John >>>=20 >>> On Fri, Jul 24, 2015 at 9:11 AM Andrus Adamchik = >>> wrote: >>>=20 >>>> Hi Hugi, >>>>=20 >>>> 1. I can't think of anything inside Cayenne that would rely on a = getter >>>> (Property.getFrom(..) is user-facing API that is not directly = related to >>>> persistence). So you should be safe otherwise. >>>>=20 >>>> 2. I am with Mike - if you can, better switch to JavaBean getters. >> You'll >>>> avoid lots of pain integrating with anything else in Java. >>>>=20 >>>> Andrus >>>>=20 >>>>> On Jul 24, 2015, at 3:32 PM, Michael Gentry = >>>> wrote: >>>>>=20 >>>>> Hi Hugi, >>>>>=20 >>>>> I don't know offhand everywhere in Cayenne that get* is required, = but >>>>> Cayenne's default templates and expectations are that the = JavaBeans >>>>> notation (get/set/is) prefixes will be used. Many other = frameworks, >> such >>>>> as Apache Tapestry, work flawlessly with Cayenne because of the >> JavaBeans >>>>> notation, but would fail if get* were missing. >>>>>=20 >>>>> I used to use EOF/Objective-C, too, and at first the get* seemed >>>> annoying, >>>>> but now within Eclipse it is easy to type "get" and let the >>>> autocompletion >>>>> popup show me my options, which you can't do without that prefix. >>>> Overall, >>>>> I think get* is a win because it is easier to find your getters = and it >>>>> makes Cayenne work with other frameworks that expect the standard >>>> prefixes. >>>>>=20 >>>>> mrg >>>>>=20 >>>>>=20 >>>>> On Fri, Jul 24, 2015 at 7:37 AM, Hugi Thordarson = >>>> wrote: >>>>>=20 >>>>>> Hi all. >>>>>>=20 >>>>>> I don=E2=80=99t use =E2=80=9Cget" prefixes on the accessors for = attributes on my >>>>>> DataObjects. This has worked flawlessly until now, but I just = stumbled >>>> onto >>>>>> a case where it will cause a failure inside Cayenne=E2=80=99s = world, i.e. when >>>>>> attempting to access property values on objects using >>>>>> org.apache.cayenne.exp.Property.getFrom( someObject ). >>>>>>=20 >>>>>> The method documentation explicitly states that a bean-style >> get-prefix >>>> is >>>>>> required, so this was to be expected. But I=E2=80=99m wondering = if there are >>>> more >>>>>> places where Cayenne depends on it and if the requirement for the >> =E2=80=9Cget=E2=80=9D >>>>>> prefix should be eliminated entirely within Cayenne=E2=80=99s = universe? (I=E2=80=99m >>>> sure >>>>>> I=E2=80=99m not the only one who is not fond of using it) >>>>>>=20 >>>>>> I got around this particular case by implementing my own =E2=80=9Cp= oor man=E2=80=99s >>>>>> KeyValueCoding=E2=80=9D (for those of you familiar with EOF), but = it would be >>>> nice >>>>>> not having to do something of that ilk. >>>>>>=20 >>>>>> Cheers, >>>>>> - hugi >>>>>>=20 >>>>>> // Hugi Thordarson >>>>>> // http://www.loftfar.is/ >>>>>> // s. 895-6688 >>>>>>=20 >>>>=20 >>>>=20 >>=20 >>=20