pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Oliver Jowett <oliver@opencloud.com>
Cc: stagirus <mamasa@stagirus.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date: Fri, 01 Oct 2010 11:09:06 +0800
Message-ID: <4CA550D2.8090407@postnewspapers.com.au> (raw)
In-Reply-To: <4CA4F536.5050704@opencloud.com>
References: <1285601721239-2855475.post@n5.nabble.com>
	<4CA0805B0200002500035F43@gw.wicourts.gov>
	<4CA101E3.5080005@opencloud.com>
	<AANLkTi=OgduBWb4XLo3bqUXJULNEvUKCAh54xhiEgOjU@mail.gmail.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>

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



view thread (53+ messages)  latest in thread

Message-ID: <4CA550D2.8090407@postnewspapers.com.au>
Permalink:  ../4CA550D2.8090407@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4CA550D2.8090407@postnewspapers.com.au

 · 

reply

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: craig@postnewspapers.com.au, oliver@opencloud.com, mamasa@stagirus.com
  Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
  In-Reply-To: <4CA550D2.8090407@postnewspapers.com.au>
  References: <1285601721239-2855475.post@n5.nabble.com> <4CA0805B0200002500035F43@gw.wicourts.gov> <4CA101E3.5080005@opencloud.com> <AANLkTi=OgduBWb4XLo3bqUXJULNEvUKCAh54xhiEgOjU@mail.gmail.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> <4CA550D2.8090407@postnewspapers.com.au>

* 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