Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 57959 invoked from network); 14 Apr 2010 22:08:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Apr 2010 22:08:51 -0000 Received: (qmail 85973 invoked by uid 500); 14 Apr 2010 22:08:50 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 85943 invoked by uid 500); 14 Apr 2010 22:08:50 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 85935 invoked by uid 99); 14 Apr 2010 22:08:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Apr 2010 22:08:50 +0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=AWL,FREEMAIL_FROM,FREEMAIL_REPLY,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of plinskey@gmail.com designates 74.125.92.25 as permitted sender) Received: from [74.125.92.25] (HELO qw-out-2122.google.com) (74.125.92.25) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Apr 2010 22:08:46 +0000 Received: by qw-out-2122.google.com with SMTP id 9so227061qwb.57 for ; Wed, 14 Apr 2010 15:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:content-type :content-transfer-encoding; bh=ES3Hy3CQajxezN8nsA+dI/M/6H6FVI6YsZdoyD09990=; b=UiBAMfzU1IEX95pNxxs210a5h2bjXAmbVKKeDq/chRJJO7pmZ7tSjCe2TYW+vlpP4T 0IhQFB7osUkRVlkipwqBjWtb/O8DoV4v5mBYlcDMMgpMkPu27HIJcvK1ZPNrs4dnSkza GShdor42gSFpnqxJomJyhC5LFgs4719qqsjLs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=In3NRMp3Nxedj6DXJ506FHn4RArd1NVZ7uSeqY26O2iknH6DIQF0XOrnk/nKxPStvh nJJnAFvc+9JiVg1dkwqm4DrjOFlltgqhuu8rywbXZ7IISOZW82gL+13TSYfJJ+EYTIMP IgJI39oTHRB3iLljK+VX8n86wMQ6iBvnSZB1s= MIME-Version: 1.0 Received: by 10.229.81.204 with HTTP; Wed, 14 Apr 2010 15:08:05 -0700 (PDT) In-Reply-To: References: From: Patrick Linskey Date: Wed, 14 Apr 2010 15:08:05 -0700 Received: by 10.229.181.16 with SMTP id bw16mr657588qcb.0.1271282905216; Wed, 14 Apr 2010 15:08:25 -0700 (PDT) Message-ID: Subject: Re: OpenJPA 1.2.x & map key as enum stored as string (probably a FAQ) To: users@openjpa.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable > Yes, I've tried that & OpenJPA wants to use the enum's ordinal instead > of its string representation. How do I force the use of its string > representation? In JPA2, you could use the EnumType annotation. In earlier versions, it looks like you could either change the default across the board via re-configuring the PersistenceMapping (a bit invasive), or you could do something like @KeyStrategy("StoreOrdinal=3Dfalse") > PS: Who's Max? ;) http://amzn.to/10UcX2 -Patrick On Wed, Apr 14, 2010 at 1:17 PM, Matthew Adams wr= ote: > Yes, I've tried that & OpenJPA wants to use the enum's ordinal instead > of its string representation. =A0How do I force the use of its string > representation? > > Thanks, > Matthew > > PS: =A0Who's Max? =A0;) > > On Wed, Apr 14, 2010 at 10:56 AM, Patrick Linskey wr= ote: >> Hi, Max! >> >> I think that @PersistentMap is your friend here. Have you tried that ann= otation? >> >> Happy sailing, >> >> -Patrick >> >> On Wed, Apr 14, 2010 at 9:59 AM, Matthew Adams = wrote: >>> Hi all, >>> >>> Sorry if this is a FAQ. =A0I can't seem to find it in the docs or googl= ing. >>> >>> I have the following scenario and just need to know which >>> OpenJPA-specific annotations to apply to my field. =A0The scenario is a >>> field of type Map where the map key is an enum that I want to store as >>> @Enumerated(EnumType.STRING) and is not an attribute of the values in >>> the map using OpenJPA 1.2.x & JPA 1.0 (can't go to JPA 2.0 yet). >>> Assume all classes use a simple @Id field of type Long. >>> >>> public enum Place { HOUSE, CAVE, LEAN_TO, BARE_SPOT; } >>> >>> @Entity >>> public class WildThing { >>> =A0/* NOTE: does **not** have a field of type Place! */ >>> =A0@Id >>> =A0protected Long id; >>> =A0protected String name; >>> } >>> >>> @Entity >>> public class WhereTheWildThingsAre { >>> >>> =A0@Id >>> =A0protected Long id; >>> >>> =A0// what annotation(s) do I put here? >>> =A0@OneToMany(cascade =3D >>> =A0 =A0{ CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST }) >>> =A0protected Map thingsByClassification >>> =A0 =A0=3D new HashMap; >>> >>> } >>> >>> Again, I want the key to be stored as the string representation of the >>> enum constant. >>> >>> TIA, >>> Matthew >>> >>> -- >>> mailto:matthew@matthewadams.me >>> skype:matthewadams12 >>> yahoo:matthewadams >>> aol:matthewadams12 >>> google-talk:matthewadams12@gmail.com >>> msn:matthew@matthewadams.me >>> http://matthewadams.me >>> http://www.linkedin.com/in/matthewadams >>> >> >> >> >> -- >> Patrick Linskey >> 202 669 5907 >> > > > > -- > mailto:matthew@matthewadams.me > skype:matthewadams12 > yahoo:matthewadams > aol:matthewadams12 > google-talk:matthewadams12@gmail.com > msn:matthew@matthewadams.me > http://matthewadams.me > http://www.linkedin.com/in/matthewadams > --=20 Patrick Linskey 202 669 5907