Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 65710 invoked from network); 18 Jan 2010 11:51:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jan 2010 11:51:04 -0000 Received: (qmail 78386 invoked by uid 500); 18 Jan 2010 11:51:04 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 78304 invoked by uid 500); 18 Jan 2010 11:51:04 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 78296 invoked by uid 99); 18 Jan 2010 11:51:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 11:51:03 +0000 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [91.199.21.18] (HELO mxa.xchangemail.de) (91.199.21.18) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 11:50:55 +0000 Received: from VAVP1E1A.vavp0m.de (10.40.201.2) by mxa.xchangemail.de (10.41.8.201) with Microsoft SMTP Server (TLS) id 8.1.358.0; Mon, 18 Jan 2010 12:50:34 +0100 Received: from VAVP0E7A.vavp0m.de ([10.46.1.70]) by VAVP1E1A.vavp0m.de ([10.41.5.27]) with mapi; Mon, 18 Jan 2010 12:50:34 +0100 From: Stephen Friedrich To: "user-java@ibatis.apache.org" Date: Mon, 18 Jan 2010 12:50:32 +0100 Subject: enums as ordinals? Thread-Topic: enums as ordinals? Thread-Index: AcqYNHAt6u6Q5kgoTXiy5TIzo2Rwaw== Message-ID: <60454457CBDFBD4DB30D4F4A5B193DED025C025434@VAVP0E7A.vavp0m.de> Accept-Language: en-US, de-DE Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, de-DE Content-Type: multipart/alternative; boundary="_000_60454457CBDFBD4DB30D4F4A5B193DED025C025434VAVP0E7Avavp0_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_60454457CBDFBD4DB30D4F4A5B193DED025C025434VAVP0E7Avavp0_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable By default iBATIS expects enums to be stored in the DB using the enum _name= s_. I am working with a legacy DB where the enum's ordinal is stored instead. On a global level I managed to do this by patching the default EnumTypeHand= ler. The only alternative that I currently see is to write a specific type handl= er for each single enum used in the project. This can't really be the ultimate solution. Is there a better solution that I have missed so far? I can't register a typehandler for the "Enum" base class, because iBATIS on= ly ever compares to the concrete class. Shouldn't there be a built-in, quick way to configure either ordinal or nam= e on a mapper level? --_000_60454457CBDFBD4DB30D4F4A5B193DED025C025434VAVP0E7Avavp0_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

By default iBATIS expects enums to = be stored in the DB using the enum _names_.

I am working with a legacy DB where= the enum's ordinal is stored instead.

 

On a global level I managed to do t= his by patching the default EnumTypeHandler.

 

The only alternative that I current= ly see is to write a specific type handler

for each single enum used in the pr= oject. This can't really be the ultimate

solution.

 

Is there a better solution that I h= ave missed so far?

I can't register a typehandler for = the "Enum" base class, because iBATIS only ever

compares to the concrete class.

 

Shouldn't there be a built-in, quic= k way to configure either ordinal or name

on a mapper level?

--_000_60454457CBDFBD4DB30D4F4A5B193DED025C025434VAVP0E7Avavp0_--