Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 53312 invoked from network); 17 Sep 2008 15:51:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2008 15:51:56 -0000 Received: (qmail 10760 invoked by uid 500); 17 Sep 2008 15:51:52 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 10745 invoked by uid 500); 17 Sep 2008 15:51:52 -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 10734 invoked by uid 99); 17 Sep 2008 15:51:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Sep 2008 08:51:52 -0700 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: local policy) Received: from [216.252.110.47] (HELO web55801.mail.re3.yahoo.com) (216.252.110.47) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 17 Sep 2008 15:50:51 +0000 Received: (qmail 96618 invoked by uid 60001); 17 Sep 2008 15:51:23 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=UYUHgb9PUJZXdG46suQjcE2i0MwDoWlYxJVcu+JgU1y/wz43nz0FVtb2Dk+C6I8oZhR/RDiHZp5KAJv/xLyfE7olxH8kRnpv1VTVSrhUUdJsIui/r1a/fub6NydcgMZD52uEz6RUb9kG4AAft3D1m+uyVoYmvqWTWT7/gsp1/7I=; X-YMail-OSG: .eWaE2YVM1lKT910zQIHa030.oJDUD9teF0yDjapmAIHfjodChKjwgwEJ9pm7ZQh79iKTIWH_875C3O8QooNxfIeKEMcBQ4B51j_LB6doglJ9hqRsErwX00EWAhYkiCLVUDIaEi7OT2sownMLWUCiC7YtJ8- Received: from [129.42.184.35] by web55801.mail.re3.yahoo.com via HTTP; Wed, 17 Sep 2008 08:51:23 PDT X-Mailer: YahooMailWebService/0.7.218.2 Date: Wed, 17 Sep 2008 08:51:23 -0700 (PDT) From: Fay Wang Reply-To: fyw300@yahoo.com Subject: Re: Example of Enum mapping (fixed numbering) To: users@openjpa.apache.org In-Reply-To: <12D996978341E849B21C51CC97F4771D010B56E0@mail3.oams.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID: <187001.96415.qm@web55801.mail.re3.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org Here is an example: @Entity public class EntityA { @Id private int id; @Enumerated( EnumType.ORDINAL ) private Measure measure; =20 public Measure getMeasure() { return measure; } =20 public void setMeasure(Measure measure) { this.measure =3D measure; } =09 public int getId() { =09return id; } =09 public void setId(int id) { =09this.id =3D id; } } public enum Measure { M1 ("M1", false), M2 ("M2", false), M3 ("M3", false), M4 ("M4", false), M5 ("M5", true); =20 private String description; private Measure(String desc){ this.description=3Ddesc; } public String desc(){return this.description;} } --- On Wed, 9/17/08, Michael Vorburger wrote= : > From: Michael Vorburger > Subject: Example of Enum mapping (fixed numbering) > To: users@openjpa.apache.org > Date: Wednesday, September 17, 2008, 8:29 AM > Does anybody have a concrete example of how to map an enum > with fixed > ordinal numbering? I have a DB which has an numeric column > where the > existing values mean something. I want to map that to an > Entity > attribute of some enum type.=20 > =20 > Reading > http://forums.oracle.com/forums/thread.jspa?threadID=3D658154 > and > http://appfuse.org/display/APF/Java+5+Enums+Persistence+with+Hibernate > I > realize standard JPA does NOT actually do this (shame! > hopefully this > will be considered in JPA 2.0). However using some kind of > Custom Field > Mapping / Value Handler / Field Strategy annotation > (http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_gui > de_mapping_custom) this probably possible... any example > handy? > =20 > Thanks, > Michael > =20 >=20 > ____________________________________________________________ >=20 > =E2=80=A2 This email and any files transmitted with it are > CONFIDENTIAL and intended > solely for the use of the individual or entity to which > they are addressed. > =E2=80=A2 Any unauthorized copying, disclosure, or distribution > of the material within > this email is strictly forbidden. > =E2=80=A2 Any views or opinions presented within this e-mail are > solely those of the > author and do not necessarily represent those of Odyssey > Financial > Technologies SA unless otherwise specifically stated. > =E2=80=A2 An electronic message is not binding on its sender. Any > message referring to > a binding engagement must be confirmed in writing and > duly signed. > =E2=80=A2 If you have received this email in error, please notify > the sender immediately > and delete the original.=0A=0A=0A