Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date
Msg-id 4CA28CCB.5020400@opencloud.com
Whole thread Raw
In response to Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)  (stagirus <mamasa@stagirus.com>)
Responses Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)  (stagirus <mamasa@stagirus.com>)
List 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

pgsql-jdbc by date:

Previous
From: stagirus
Date:
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Next
From:
Date:
Subject: Re: setQueryTimout()