Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-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

pgsql-bugs by date

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

pgsql-jdbc by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group