Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: stagirus <mamasa(at)stagirus(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date: 2010-09-29 00:48:11
Message-ID: 4CA28CCB.5020400@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-jdbc

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Aswin J 2010-09-29 07:08:37 BUG #5682: Postgres Service crashes with exception 0xC0000135
Previous Message stagirus 2010-09-28 23:44:51 Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)

Browse pgsql-jdbc by date

  From Date Subject
Next Message rsmogura 2010-09-29 08:25:57 Re: setQueryTimout()
Previous Message stagirus 2010-09-28 23:44:51 Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)