From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tom Dunstan <pgsql@tomd.cc>
Cc: Hudson, Derrick <dhudson@redcom.com>
Cc: Marc G. Fournier <scrappy@hub.org>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] JPA + enum == Exception
Date: Thu, 07 Feb 2013 23:55:22 -0500
Message-ID: <28690.1360299322@sss.pgh.pa.us> (raw)
In-Reply-To: <CAPPfruyta0A0xGhG4Zh785sS0_FZ8GczzcjZGXo2yfPhaDxuaA@mail.gmail.com>
References: <EDDA5C6D-77E3-4C56-B33B-277E7FB32A12@hub.org>
<401084E5E73F4241A44F3C9E6FD794289CE24D03@exch-01>
<CAPPfruyta0A0xGhG4Zh785sS0_FZ8GczzcjZGXo2yfPhaDxuaA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Tom Dunstan <pgsql@tomd.cc> writes:
> ... That works ok, but when attempting to use a prepared statement:
> ps = con.prepareStatement("insert into enumcast values (?)");
> ps.setString(1, "meh");
> ps.executeUpdate();
> we get a
> org.postgresql.util.PSQLException: ERROR: column "current_mood" is of
> type mood but expression is of type character varying
> Hint: You will need to rewrite or cast the expression.
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.)
Enums are not suffering any special hardship here, and I'd be against
weakening the type system to give them a special pass.
regards, tom lane
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql@tomd.cc, dhudson@redcom.com, scrappy@hub.org, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] JPA + enum == Exception
In-Reply-To: <28690.1360299322@sss.pgh.pa.us>
References: <EDDA5C6D-77E3-4C56-B33B-277E7FB32A12@hub.org> <401084E5E73F4241A44F3C9E6FD794289CE24D03@exch-01> <CAPPfruyta0A0xGhG4Zh785sS0_FZ8GczzcjZGXo2yfPhaDxuaA@mail.gmail.com> <28690.1360299322@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox