Re: JBoss w/int8 primary keys in postgres ... - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: JBoss w/int8 primary keys in postgres ...
Date
Msg-id 20030906222528.GD6486@opencloud.com
Whole thread Raw
In response to JBoss w/int8 primary keys in postgres ...  (James Robinson <jlrobins@socialserve.com>)
Responses Re: JBoss w/int8 primary keys in postgres ...  (Paul Thomas <paul@tmsl.demon.co.uk>)
List pgsql-jdbc
On Sat, Sep 06, 2003 at 02:38:40PM -0400, James Robinson wrote:

> Is there any hope to get JBoss + PG JDBC to do this typecasting
> automatically? Assuming JBoss is using PreparedStatements for its dirty
> work, could the setLong() method on the JDBC driver's PreparedStatement
>  implementation possibly always punch in the trailing '::int8' ?

Something like this was tried without much success. See:

  http://archives.postgresql.org/pgsql-jdbc/2002-10/msg00163.php

http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java#rev1.6

http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java#rev1.12

Reading that thread, the change that was tried was quoting the value to get
an implicit cast from 'text' to the expected type -- whatever it was --
happening.

Perhaps it's reasonable to have setLong() always append ::int8 since that
does reflect the possible range of the parameter's type -- anyone more
familiar with this area want to comment? I guess that you end up with the
reverse problem of things that expect an int4 value but use setLong() will
break, but maybe that is less common and is going to have other problems
anyway if you try to use a java long that's larger than int4 can handle ..

-O

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: JBoss w/int8 primary keys in postgres ...
Next
From: Paul Thomas
Date:
Subject: Re: JBoss w/int8 primary keys in postgres ...