Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3qmq-0000QI-Gx for pgsql-jdbc@arkaria.postgresql.org; Fri, 08 Feb 2013 16:26:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U3qmo-0002wY-W0 for pgsql-jdbc@arkaria.postgresql.org; Fri, 08 Feb 2013 16:26:51 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3qmV-0002gC-B6 for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 16:26:31 +0000 Received: from mail63.csoft.net ([205.205.214.4]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3qmT-0003jY-5f for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 16:26:30 +0000 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id E651628FC1; Fri, 8 Feb 2013 11:26:27 -0500 (EST) Received: by leary.csoft.net (Postfix, from userid 1112) id E31B71FBCD; Fri, 8 Feb 2013 11:26:27 -0500 (EST) Date: Fri, 8 Feb 2013 11:26:27 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Tom Dunstan cc: Tom Lane , "Hudson, Derrick" , "Marc G. Fournier" , "pgsql-jdbc@postgresql.org" Subject: Re: [HACKERS] JPA + enum == Exception In-Reply-To: Message-ID: References: <401084E5E73F4241A44F3C9E6FD794289CE24D03@exch-01> <28690.1360299322@sss.pgh.pa.us> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On Fri, 8 Feb 2013, Tom Dunstan wrote: > On 8 February 2013 15:25, Tom Lane wrote: > > > AFAIK this is just business as usual with JDBC: setString() implies that > > the parameter is of a string type. It'll fall over if the type actually > > required is anything but a string. (I'm no Java expert, but I seem to > > recall that using setObject instead is the standard workaround.) > > > > Yes, you can use setObject(1, "enumval", Types.OTHER). I was hoping > that setString might work, as mapping java enum values to strings in > the database is a very common ORM technique that is built into > basically all major ORMs including all that support the JPA standard, > and it leads to people using varchars instead of typesafe enums in > their dbs. The other workaround is to use the url parameter stringtype=unspecified to have setString always bind to unknown instead of varchar, which then shouldn't require any code changes. Kris Jurka -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc