Re: Using java.lang.Character for "char" data type

From: Kris Jurka <books(at)ejurka(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Віталій Тимчишин <tivv00(at)gmail(dot)com>, PG-JDBC Mailing List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Using java.lang.Character for "char" data type
Date: 2010-05-24 18:25:51
Message-ID: alpine.BSO.2.00.1005241406480.1152@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Sat, 22 May 2010, Craig Ringer wrote:

> So really the appropriate SQL type for Java 'Character' is varchar(1) ?

Yes.

> And a PostgreSQL 'char' (bpchar, not character(1)) maps best to a Java
> 'Byte' ?

I'm not so sure about that. "char" is still intended to represent a
textual identifier, not a numeric value as Byte does. Additionally you
can't store 0 in a "char".

When you're talking about a mapping there's two directions, setObject and
getObject, and they're not always symmetric. If we allowed setObject with
a Character to map to varchar, then I would not expect getObject to return
a Character, I'd expect a String.

Kris Jurka

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Altaf Malik 2010-05-26 08:50:16 Function with raise notice statements taking too long
Previous Message Lew 2010-05-23 14:42:57 Re: Error in connector or driver with big bytea