From: | Andreas Joseph Krogh <andreak(at)officenet(dot)no> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | ResultSet.getClob() causing problems when used with JPA's @Lob |
Date: | 2011-02-06 23:01:21 |
Message-ID: | 201102070001.22259.andreak@officenet.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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.java: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(ClobTypeDescriptor.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?
--
Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Senior Software Developer / CTO
Public key: http://home.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Rosenholmveien 25 | know how to do a thing and to watch |
1414 Trollåsen | somebody else doing it wrong, without |
NORWAY | comment. |
Org.nr: NO 981 479 076 | |
| |
Tlf: +47 24 15 38 90 | |
Fax: +47 24 15 38 91 | |
Mobile: +47 909 56 963 | |
------------------------+---------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Radosław Smogura | 2011-02-07 08:11:20 | Re: ResultSet.getClob() causing problems when used with JPA's @Lob |
Previous Message | Maciek Sakrejda | 2011-02-06 17:31:11 | Re: SQL select doesn't work |