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

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-jdbc(at)postgresql(dot)org>,"stagirus" <mamasa(at)stagirus(dot)com>
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date: 2010-09-27 16:30:35
Message-ID: 4CA0805B0200002500035F43@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-jdbc

stagirus <mamasa(at)stagirus(dot)com> wrote:

> Ideally DB Engine/JDBC Drivers should be flexible(smart?) enough
> to recognize integer values for boolean values. It is unfortunate
> that RDMBS vendors nor ANSI SQL standardized boolean values. Am I
> making sense?

Sure. I finally tracked down a current copy of the JDBC spec. For
some reason, this seems to have become more difficult to find in
recent months; if anyone else is looking, I found it here:

http://jcp.org/aboutJava/communityprocess/final/jsr221/index.html

The relevant portions are TABLE B-5 and TABLE B-6. What matters for
purposes of this discussion is that, when the driver is specifically
requested to convert between any of these Java classes:

String
java.math.BigDecimal
Boolean
Byte
Short
Integer
Long
Float
Double

and any of these database types:

TINYINT
SMALLINT
INTEGER
BIGINT
REAL
FLOAT
DOUBLE
DECIMAL
NUMERIC
BIT
BOOLEAN
CHAR
VARCHAR
LONGVARCHAR

it should attempt to do so. Obviously that can sometimes fail due
to size or format issues. But getBoolean against a SMALLINT is
clearly supposed to be attempted on demand. I didn't happen across
the specification of how values map there, but in the absence of
evidence to the contrary I'd assume zero is false and anything else
is true; Likewise, setObject using a Boolean against a SMALLINT
target is supposed to work.

What kinds of values do you see in the SMALLINT column when you set
a TRUE into a SMALLINT column? 1? -1?

-Kevin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ashesh Vashi 2010-09-27 16:44:47 Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Previous Message stagirus 2010-09-27 15:35:21 Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)

Browse pgsql-jdbc by date

  From Date Subject
Next Message stagirus 2010-09-27 17:08:52 Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Previous Message stagirus 2010-09-27 15:35:21 Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)