pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-jdbc@postgresql.org
To: stagirus <mamasa@stagirus.com>
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date: Mon, 27 Sep 2010 11:30:35 -0500
Message-ID: <4CA0805B0200002500035F43@gw.wicourts.gov> (raw)
In-Reply-To: <1285601721239-2855475.post@n5.nabble.com>
References: <4CA064B50200002500035F29@gw.wicourts.gov>
	<1285601721239-2855475.post@n5.nabble.com>

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



view thread (53+ messages)  latest in thread

Message-ID: <4CA0805B0200002500035F43@gw.wicourts.gov>
Permalink:  ../4CA0805B0200002500035F43@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4CA0805B0200002500035F43@gw.wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, pgsql-jdbc@postgresql.org, mamasa@stagirus.com
  Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
  In-Reply-To: <4CA0805B0200002500035F43@gw.wicourts.gov>
  References: <4CA064B50200002500035F29@gw.wicourts.gov> <1285601721239-2855475.post@n5.nabble.com> <4CA0805B0200002500035F43@gw.wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox