Re: ResultSet.getClob() causing problems when used with JPA's @Lob - Mailing list pgsql-jdbc

From Radosław Smogura
Subject Re: ResultSet.getClob() causing problems when used with JPA's @Lob
Date
Msg-id 201102070911.20245.rsmogura@softperience.eu
Whole thread Raw
In response to ResultSet.getClob() causing problems when used with JPA's @Lob  (Andreas Joseph Krogh <andreak@officenet.no>)
Responses Re: ResultSet.getClob() causing problems when used with JPA's @Lob  (Andreas Joseph Krogh <andreak@officenet.no>)
List pgsql-jdbc
Hi,
PGSQL doesn't have CLOB type, instead JDBC uses LOB, but PGSQL doesn't have
"clear" lob field type. It uses in table column with type OID, and supporting
table for storing large objects.

Look at bug submited by me
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4617
Should be fixed in 3.6.1 release.

Kind regards,
Radosław Smogura
http://softperience.eu

Andreas Joseph Krogh <andreak@officenet.no> Monday 07 February 2011 00:01:21
> Hi.
>
> 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:
>
> Caused by: org.postgresql.util.PSQLException: Bad value for type long : Hei
>         at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.j
> ava:2796) at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.
> java:2019) at
> org.postgresql.jdbc4.Jdbc4ResultSet.getClob(Jdbc4ResultSet.java:43) at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.getClob(AbstractJdbc2ResultSet.
> java:384) at
> 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
> 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?

pgsql-jdbc by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: ResultSet.getClob() causing problems when used with JPA's @Lob
Next
From: Andreas Joseph Krogh
Date:
Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob