Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3opk-0006JR-QG for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Feb 2013 14:21:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U3opj-0002rK-MH for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Feb 2013 14:21:43 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3opi-0002r1-FR for pgsql-hackers@postgresql.org; Fri, 08 Feb 2013 14:21:42 +0000 Received: from nm33-vm5.bullet.mail.bf1.yahoo.com ([72.30.239.205]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3opg-0001hs-1S for pgsql-hackers@postgresql.org; Fri, 08 Feb 2013 14:21:41 +0000 Received: from [98.139.214.32] by nm33.bullet.mail.bf1.yahoo.com with NNFMP; 08 Feb 2013 14:21:39 -0000 Received: from [98.139.212.217] by tm15.bullet.mail.bf1.yahoo.com with NNFMP; 08 Feb 2013 14:21:39 -0000 Received: from [127.0.0.1] by omp1026.mail.bf1.yahoo.com with NNFMP; 08 Feb 2013 14:21:39 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 88623.37194.bm@omp1026.mail.bf1.yahoo.com Received: (qmail 29722 invoked by uid 60001); 8 Feb 2013 14:21:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1360333298; bh=w5O5TJCMULtySOImg17NClaaRm0IacML61S1ZKZrWgQ=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=3VqIGk3XoY0sl62UlSRHJxE9J3yvwFItxmTqYmczGTtP52YyWKjof282OXsO2b/WkVNVpyMZoc7Ic1a9P2GoWTumFtERaTA0/R8tQqIjRVVBcdrLwNJcUexI3P033+ijUnILi1sqs9wz8zHdrJ4rOmR9Ofq5sDcIGVQQfvwO9/M= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=G/vfqUQtFqUSyEjNBagi/t+9JYkIb2Eexd8NDjIBQ6gdm0OBixd9h2Y3ZwWCD77FDxwfJj8TYa9Lustk5VQ4LIsEQYd6FIiP+WnMCufIx10onW/JDr+TNDntHnAcw9aP40Qm+lHUW1P3sjusbiOR+0FWWmZbRIeu8b70hoLGAyA=; X-YMail-OSG: Gl3sPQIVM1lxwwCbdU96XCPpQudnWjZos22Xkuz3._J4wwo XNvThAXMbqcDTriXEUgy_DHtuBm8azZt6mEKhJr4edDrq9k_f8Hsz.CDA1aD GMFwNkiMQbJDl5eXIaAaO6ZcREmWaSI.vse48lWGPQDRLqoBO4rP9bjbIUr8 7SMDiebwGY4e.AyALwNCdPrWb_o01eaFt7KfWVhsLeag33JxmIcHgjvtKum3 kS65Qk7m7RxN5_GszrDaoHhBWADPklGIib_Ax_bIQH8TUY4vQ18e43dQFbvJ lwTHY8oODtVwHLSWTAuZDnxb9lqIx3P9SY8G3X3UfWx__nINkQRW3XbSyW0f 9nVQJBxLYMJi8vMO4eayIy2izKSoXh8MLybB6blmlKwMjjMa8HDk8k5tDBoq zKyiU23z07TcuOezl.niT0G76Qp63adURT5.hTc0muQt7487LwJnh.70dgkZ wRfhJdlttnQ1sKNCEJrqJtpUwpWh6NbsTZpIHH640kT28hXH6K7xUz1fAjOR gm3pDg3cY7FAmbVVkdXm0hoM46BPoPUXYqRvvFH0ux7YAZDDGHnBUurHWAuc Y68YpD_HHQr8H5Ue4W8NlflHMx6ew6n.2t1.4ig-- Received: from [76.255.19.161] by web162902.mail.bf1.yahoo.com via HTTP; Fri, 08 Feb 2013 06:21:38 PST X-Rocket-MIMEInfo: 001.001, VG9tIExhbmUgPHRnbEBzc3MucGdoLnBhLnVzPiB3cm90ZToKCj4.IHdoZW4gYXR0ZW1wdGluZyB0byB1c2UgYSBwcmVwYXJlZCBzdGF0ZW1lbnQ6Cj4KPj7CoMKgwqDCoCBwcyA9IGNvbi5wcmVwYXJlU3RhdGVtZW50KCJpbnNlcnQgaW50byBlbnVtY2FzdCB2YWx1ZXMgKD8pIik7Cj4.wqDCoMKgwqAgcHMuc2V0U3RyaW5nKDEsICJtZWgiKTsKPj7CoMKgwqDCoCBwcy5leGVjdXRlVXBkYXRlKCk7Cj4KPj4gd2UgZ2V0IGEKPgo.PiBvcmcucG9zdGdyZXNxbC51dGlsLlBTUUxFeGNlcHRpb246IEVSUk9SOiBjb2wBMAEBAQE- X-Mailer: YahooMailWebService/0.8.132.503 References: <401084E5E73F4241A44F3C9E6FD794289CE24D03@exch-01> <28690.1360299322@sss.pgh.pa.us> Message-ID: <1360333298.29653.YahooMailNeo@web162902.mail.bf1.yahoo.com> Date: Fri, 8 Feb 2013 06:21:38 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: [JDBC] JPA + enum == Exception To: Tom Lane , Tom Dunstan Cc: "Hudson, Derrick" , "Marc G. Fournier" , "pgsql-jdbc@postgresql.org" , "pgsql-hackers@postgresql.org" In-Reply-To: <28690.1360299322@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Tom Lane wrote: >> when attempting to use a prepared statement: > >>=A0=A0=A0=A0 ps =3D con.prepareStatement("insert into enumcast values (?)= "); >>=A0=A0=A0=A0 ps.setString(1, "meh"); >>=A0=A0=A0=A0 ps.executeUpdate(); > >> we get a > >> org.postgresql.util.PSQLException: ERROR: column "current_mood" >> is of type mood but expression is of type character varying >>=A0=A0 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.=A0 It'll fall over if the type actually > required is anything but a string.=A0 (I'm no Java expert, but I seem to > recall that using setObject instead is the standard workaround.) Right.=A0 It is spelled out pretty specifically in the JDBC spec: http://download.oracle.com/otn-pub/jcp/jdbc-4_1-mrel-spec/jdbc4.1-fr-spec.p= df Table B-2 governs setting PreparedStatement parameters with setString and similar methods, while tables B-4 and B-5 cover the setObject methods.=A0 It is clearly not unusual for other vendors to extend the JDBC specification to make life easier for those writing ORMs, etc.; but the behavior of the current PostgreSQL JDBC driver is doing all that is required by the spec. > Enums are not suffering any special hardship here, and I'd be against > weakening the type system to give them a special pass. This is not entirely unrelated to the discussions about allowing broader use of automatic casting server-side.=A0 It seems to me that on one side of the argument is the idea that strict typing reduces bugs and doesn't lead to problems with ambiguity, especially as things change; and on the other side the argument is that where no ambiguity exists we would make life easier for developers of applications or access tools if we relexed things beyond what the related specifications require, and that not doing so discourages adoption.=A0 I think that all the same arguments apply here with equal force, on both sides of the issue. The problem with this debate has always been that both sides are completely right.=A0 Those are always the toughest to resolve.=A0 It comes down to which evils we tolerate to garner which benefits.=A0 It seems that in such cases inertia tends to win.=A0 I'm not so sure that it should.=A0 An ideal solution would find some way to address the concerns of both sides, but so far that has eluded us when it comes to the type system. -Kevin --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers