Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C110A1337BA3 for ; Sun, 6 Feb 2011 19:20:00 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 89957-05 for ; Sun, 6 Feb 2011 23:19:54 +0000 (UTC) X-Greylist: delayed 00:18:15.803804 by SQLgrey-1.7.6 Received: from ns1.officenet.no (unknown [195.159.87.244]) by mail.postgresql.org (Postfix) with ESMTP id 19ADB1336B42 for ; Sun, 6 Feb 2011 19:19:52 -0400 (AST) Received: from [79.161.204.50] (helo=andreak-precision-m6300.localnet) by ns1.officenet.no with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1PmDbp-0004yh-4s for pgsql-jdbc@postgresql.org; Mon, 07 Feb 2011 00:01:35 +0100 From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-jdbc@postgresql.org Subject: ResultSet.getClob() causing problems when used with JPA's @Lob Date: Mon, 7 Feb 2011 00:01:21 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.35-25-generic; KDE/4.6.0; x86_64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201102070001.22259.andreak@officenet.no> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201102/33 X-Sequence-Number: 21431 Hi. I have a varchar-column in a table which maps to a field (of type String) i= n a=20 JPA-entity. When marking that String-property with the JPA @Lob-annotation,= =20 using Hibernate as my JPA-provider, it stops working as expected when using= =20 PostgreSQL (works as expected on Oracle and SQL Server). The problem is tha= t=20 Hibernate, correctly, calls ResultSet.getClob() but PG internally calls=20 getLong(), which obviously won't work with varchar-types, resulting in: Caused by: org.postgresql.util.PSQLException: Bad value for type long : Hei at=20 org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.j= ava:2796) at=20 org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.= java:2019) at org.postgresql.jdbc4.Jdbc4ResultSet.getClob(Jdbc4ResultSet.java:= 43) at=20 org.postgresql.jdbc2.AbstractJdbc2ResultSet.getClob(AbstractJdbc2ResultSet.= java:384) at=20 org.hibernate.type.descriptor.sql.ClobTypeDescriptor$4.doExtract(ClobTypeDe= scriptor.java:104) After googling around I see this issue has come up before: http://archives.postgresql.org/pgsql-jdbc/2010-02/msg00004.php One is encurraged to use ResultSet.getString() instead. Hm, well - being at= =20 Hibernate's mercy here, I don't really have that luxury. So, is PG's JDBC- driver going to fix this flaw (IMNSHO it is a flaw) or is there consensus i= n the=20 PG-community that clobs are special and are not to be treated as=20 Strings/varchars? =2D-=20 Andreas Joseph Krogh Senior Software Developer / CTO Public key: http://home.officenet.no/~andreak/public_key.asc =2D-----------------------+---------------------------------------------+ OfficeNet AS | The most difficult thing in the world is to | Rosenholmveien 25 | know how to do a thing and to watch | 1414 Troll=E5sen | somebody else doing it wrong, without | NORWAY | comment. | Org.nr: NO 981 479 076 | | | | Tlf: +47 24 15 38 90 | | =46ax: +47 24 15 38 91 | | Mobile: +47 909 56 963 | | =2D-----------------------+---------------------------------------------+