Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 66A121337B39 for ; Mon, 7 Feb 2011 04:11:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 80353-02 for ; Mon, 7 Feb 2011 08:11:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.postgresql.org (Postfix) with ESMTP id C9FDF1337B34 for ; Mon, 7 Feb 2011 04:11:19 -0400 (AST) Received: from radek.localnet (87-204-194-135.dg-net.pl [87.204.194.135]) by mail.softperience.eu (Postfix) with ESMTPA id 70A11C000CD; Mon, 7 Feb 2011 09:11:22 +0100 (CET) From: =?utf-8?q?Rados=C5=82aw_Smogura?= To: pgsql-jdbc@postgresql.org Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob Date: Mon, 7 Feb 2011 09:11:20 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.36-gentoo-r5; KDE/4.4.5; x86_64; ; ) Cc: Andreas Joseph Krogh References: <201102070001.22259.andreak@officenet.no> In-Reply-To: <201102070001.22259.andreak@officenet.no> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201102070911.20245.rsmogura@softperience.eu> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201102/34 X-Sequence-Number: 21432 Hi, PGSQL doesn't have CLOB type, instead JDBC uses LOB, but PGSQL doesn't have= =20 "clear" lob field type. It uses in table column with type OID, and supporti= ng=20 table for storing large objects. Look at bug submited by me=20 http://opensource.atlassian.com/projects/hibernate/browse/HHH-4617 Should be fixed in 3.6.1 release. Kind regards, Rados=C5=82aw Smogura http://softperience.eu Andreas Joseph Krogh Monday 07 February 2011 00:01:21 > Hi. >=20 > I have a varchar-column in a table which maps to a field (of type String) > in a JPA-entity. When marking that String-property with the JPA > @Lob-annotation, using Hibernate as my JPA-provider, it stops working as > expected when using PostgreSQL (works as expected on Oracle and SQL > Server). The problem is that Hibernate, correctly, calls > ResultSet.getClob() but PG internally calls getLong(), which obviously > won't work with varchar-types, resulting in: >=20 > Caused by: org.postgresql.util.PSQLException: Bad value for type long : H= ei > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet= =2Ej > ava:2796) at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSe= t. > java:2019) at > org.postgresql.jdbc4.Jdbc4ResultSet.getClob(Jdbc4ResultSet.java:43) at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.getClob(AbstractJdbc2ResultSe= t. > java:384) at > org.hibernate.type.descriptor.sql.ClobTypeDescriptor$4.doExtract(ClobType= De > scriptor.java:104) >=20 > After googling around I see this issue has come up before: > http://archives.postgresql.org/pgsql-jdbc/2010-02/msg00004.php >=20 > One is encurraged to use ResultSet.getString() instead. Hm, well - being = at > 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 > in the PG-community that clobs are special and are not to be treated as > Strings/varchars?