Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 93027 invoked from network); 17 Jan 2008 22:13:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jan 2008 22:13:08 -0000 Received: (qmail 35952 invoked by uid 500); 17 Jan 2008 22:12:44 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 35943 invoked by uid 500); 17 Jan 2008 22:12:44 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 35925 invoked by uid 99); 17 Jan 2008 22:12:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2008 14:12:44 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of blacknext@gmail.com designates 64.233.162.233 as permitted sender) Received: from [64.233.162.233] (HELO nz-out-0506.google.com) (64.233.162.233) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2008 22:12:19 +0000 Received: by nz-out-0506.google.com with SMTP id f1so3131219nzc.37 for ; Thu, 17 Jan 2008 14:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=RsDqIDeiZrNjqo3H2QaUaRSHa7uw7e/8qDjFbVqR7BY=; b=GSR6Onvs+/jnq2CfJ9yGt56xw88Pg0+LPf5TJtA1iU/bShxMYWwgAzSeDrPT3ScNU5mzCj2BJg3jgpjcJK+I/eHD8Xby9DldNL5SEkOAfAaTwhhiBw8IShL/4wNELt2zkl9lEyihM1KhOgt2Gt3bpSh4+yZGP556PFKEJAQn/AU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ejo2khtM/x9Kc4ucFjMwJ+DPwa6Lt7NzN9gpGP9yXOMVwNxerMjy6Q0ztS7GR6tVQJtGVLTj+JnATUHMB45QcTGRA9ScMwRWDVnl31DFbVFkEWirGSrV8iYrATF14HEcx+DX973ZKMe1KhVaY+MpNAHtWrx2OyKVHSGRjdQZhQ8= Received: by 10.142.194.1 with SMTP id r1mr1625161wff.197.1200607943810; Thu, 17 Jan 2008 14:12:23 -0800 (PST) Received: by 10.142.52.17 with HTTP; Thu, 17 Jan 2008 14:12:23 -0800 (PST) Message-ID: Date: Thu, 17 Jan 2008 17:12:23 -0500 From: "Michael Gentry" To: user@cayenne.apache.org Subject: Re: Enum best practices In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org The enumeration example I have on the wiki (which I used with Cayenne 1.2) allowed for human-suitable names that differed from the actual backend representation and allowed you to use localization for different presentations (useful in a web application). I'm not sure if that would be applicable in your situation, though. I wasn't even really promoting that feature for a native Cayenne implementation, but if there is a need for it ... /dev/mrg On Jan 17, 2008 3:20 PM, Kevin Menard wrote: > On 1/17/08 9:47 AM, "Michael Gentry" wrote: > > > Ari, I was going to mention on the other thread (with Kevin) that it > > would be nice if you could map the enumerated values in Cayenne > > Modeler. I believe Andrus even mentioned keeping the mapping in the > > XML files, too. The modeler could generate the code for the enums, > > too, as you said. This would free the user from having to write the > > boilerplate code themselves. I still see needing two types of > > enumerations -- integer and string based values. I can't really see > > the need for floating point values at this time. > > Yes, what Ari mentioned sounds nice. > > I could see value in "composite" enums as well, though. I can't think of a > better term, but they're basically enums with fields that could then be > mapped to DB columns. > > For example, we use FedEx to process our shipments. The FedEx API has codes > for each service, but the codes are not really in a suitable form for a > customer. So, we store the code and the textual description as two columns > in the table. The set of values is largely fixed, but as we offer new > shipping methods (e.g., we started offering USPS), we added more rows to the > table. > > It'd be nice if there were a way to map the rows in that table as enum > instances (Java5 or otherwise) automatically. The code could be > considerably simplified (I'm a big fan of switching with Java5 enums), but > maintain the flexibility of a DB backend. > > I'm acutely aware that this is likely a pipedream though, given the invasive > nature of it all. > > -- > Kevin > >