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.phphttp://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java#rev1.6http://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