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

From Kevin Grittner
Subject Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date
Msg-id 4CA0805B0200002500035F43@gw.wicourts.gov
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>)
Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
stagirus <mamasa@stagirus.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

pgsql-jdbc by date:

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