Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A1AAB133616B for ; Tue, 28 Sep 2010 21:48:29 -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 89871-05 for ; Wed, 29 Sep 2010 00:48:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by mail.postgresql.org (Postfix) with ESMTP id 0BA411337B47 for ; Tue, 28 Sep 2010 21:48:21 -0300 (ADT) Received: from 121-98-80-66.bitstream.orcon.net.nz ([121.98.80.66] helo=[192.168.1.2]) by tremor.opencloud.co.nz with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P0kqH-000133-1V; Wed, 29 Sep 2010 13:48:17 +1300 Message-ID: <4CA28CCB.5020400@opencloud.com> Date: Wed, 29 Sep 2010 13:48:11 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: stagirus CC: pgsql-jdbc@postgresql.org Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) References: <4CA064B50200002500035F29@gw.wicourts.gov> <1285601721239-2855475.post@n5.nabble.com> <4CA0805B0200002500035F43@gw.wicourts.gov> <4CA101E3.5080005@opencloud.com> <4CA1743F.2060301@postnewspapers.com.au> <4CA18729.90401@postnewspapers.com.au> <1285701298407-2865634.post@n5.nabble.com> <4CA22C3C0200002500036065@gw.wicourts.gov> <1285716712781-2916249.post@n5.nabble.com> In-Reply-To: <1285716712781-2916249.post@n5.nabble.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201009/74 X-Sequence-Number: 20944 stagirus wrote: > You have already noted above that boolean values and integer values are > interchangeable as per the JDBC 4.0 Spec. They're not actually - see my post. You can ask the driver to convert between types for you, but Hibernate does not appear to be doing that (presumably because you've told it that the column is a boolean, which doesn't match your DDL!) To repeat my suggestions: * use a real boolean column in their schema (I mean, the data you're representing IS a boolean value in this case, right?); or * use setObject(column, value, Types.SMALLINT) instead of the implied setBoolean() call when setting the column (this may be tricky to do since you have a layer between you and the driver, but that's not really the driver's fault..); or * add a suitable implicit cast on the backend side from boolean -> smallint (not sure if this works, haven't looked at the details) Do any of these work for you? The first suggestion seems to be the simplest to me, since you really are storing a boolean, not a smallint, and you have control over the DDL. -O