Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 660AA1337B54 for ; Fri, 1 Oct 2010 00:09:25 -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 00232-01 for ; Fri, 1 Oct 2010 03:09:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 0096D1337B50 for ; Fri, 1 Oct 2010 00:09:17 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 0F4A3AF18B; Fri, 1 Oct 2010 11:09:15 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Gp5nH3ED5Y-y; Fri, 1 Oct 2010 11:09:09 +0800 (WST) Received: from [10.1.1.4] (203-173-29-204.dyn.iinet.net.au [203.173.29.204]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id AABF8AF18A; Fri, 1 Oct 2010 11:09:08 +0800 (WST) Message-ID: <4CA550D2.8090407@postnewspapers.com.au> Date: Fri, 01 Oct 2010 11:09:06 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Thunderbird/3.1.4 MIME-Version: 1.0 To: Oliver Jowett CC: stagirus , pgsql-jdbc@postgresql.org Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) References: <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> <4CA28CCB.5020400@opencloud.com> <1285762010765-3005405.post@n5.nabble.com> <4CA338F8.80902@opencloud.com> <4CA499DB.8000807@postnewspapers.com.au> <4CA4F536.5050704@opencloud.com> In-Reply-To: <4CA4F536.5050704@opencloud.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.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201010/1 X-Sequence-Number: 20969 On 10/01/2010 04:38 AM, Oliver Jowett wrote: > This is not correct. I covered this in a previous mail. [snip] > So, in summary: If you explicitly ask for a Java boolean to be mapped to > a JDBC SMALLINT, by passing Types.SMALLINT to setObject(), then that > should be supported and the driver will do the conversion for you; if > that doesn't work, that's a bug! However, if you don't specify a type > when calling setObject() or setBoolean(), it is mapped to BOOLEAN. If > BOOLEAN is then not a suitable type for the actual query you're trying > to run, then you'll get a SQL error, but that's not the driver's fault, > it just did what you asked! Aah, thanks for the clarification. I didn't notice your earlier message on the topic. Given that, it's pretty clear that the OP has to fix their app to: - Trust Hibernate to generate their DDL, taking care of their db portability issues; - Use per-database DDL with the data types Hibernate expects; - Use a short in Java if they want a short in the database, and convert it in their accessor methods; or - Use a Hibernate UserType to call the appropriate set() and get() JDBC methods, overriding the default type-based options in the dialect. -- Craig Ringer