Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 07D811337B7D for ; Thu, 30 Sep 2010 19:10:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 64687-01 for ; Thu, 30 Sep 2010 22:09:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.catalyst.net.nz (bertrand.catalyst.net.nz [202.78.240.40]) by mail.postgresql.org (Postfix) with ESMTP id 95DEB1337B56 for ; Thu, 30 Sep 2010 19:09:36 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 6AEE63203E for ; Fri, 1 Oct 2010 11:09:34 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0zCkeIH804BY for ; Fri, 1 Oct 2010 11:09:33 +1300 (NZDT) Received: from [IPv6:2404:130:0:1000:222:15ff:fe5c:2471] (unknown [IPv6:2404:130:0:1000:222:15ff:fe5c:2471]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id D0BB531F37 for ; Fri, 1 Oct 2010 11:09:33 +1300 (NZDT) Message-ID: <4CA50A9D.2030707@catalyst.net.nz> Date: Fri, 01 Oct 2010 11:09:33 +1300 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100915 Lightning/1.0b1 Thunderbird/3.0.8 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) References: <1285701298407-2865634.post@n5.nabble.com> <4CA22C3C0200002500036065@gw.wicourts.gov> <1285716712781-2916249.post@n5.nabble.com> <4CA28CCB.5020400@opencloud.com> <1285762010765-3005405.post@n5.nabble.com> <4CA338F8.80902@opencloud.com> <4CA499DB.8000807@postnewspapers.com.au> <4CA4F536.5050704@opencloud.com> <1285880740264-3047671.post@n5.nabble.com> <4CA503A2.7010706@opencloud.com> <1285883402563-3047721.post@n5.nabble.com> In-Reply-To: <1285883402563-3047721.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/97 X-Sequence-Number: 20967 On 01/10/10 10:50, stagirus wrote: > Oliver: Thank you for your generous response. The options you suggested were > not yet viable. Disagreeing is part of human nature. No worries there. > > But if you review Craig's remarks carefully, this issue is likely outside > the scope of JDBC drivers. It is more to do with the Postgresql DB Engine > that is not happy to cast or convert boolean values to SMALLINT columns. > > Craig.. is my interpretation of your comments right? > > This could be an interesting related factor (using 9.0 here): test=# create table smallinttest(val smallint); CREATE TABLE test=# create table booltest(val bool); CREATE TABLE test=# insert into booltest values (1); ERROR: column "val" is of type boolean but expression is of type integer LINE 1: insert into booltest values (1); test=# insert into booltest values ((1::smallint)::bool); ERROR: cannot cast type smallint to boolean LINE 1: insert into booltest values ((1::smallint)::bool); ^ ^ HINT: You will need to rewrite or cast the expression. test=# insert into booltest values (1::bool); INSERT 0 1 test=# insert into smallinttest values (true); ERROR: column "val" is of type smallint but expression is of type boolean LINE 1: insert into smallinttest values (true); ^ HINT: You will need to rewrite or cast the expression. test=# insert into smallinttest values (true::smallint); ERROR: cannot cast type boolean to smallint LINE 1: insert into smallinttest values (true::smallint); ^ test=# insert into smallinttest values (true::int); INSERT 0 1 So looks like we are missing type casts BOOLEAN <-> SMALLINT, given that we can happily cast to and from INTEGER. Before getting too excited, note that the server is clearly not doing automated casts under any circumstances, I had to coerce it - so might not help you even if we added such casts. Cheers Mark