Re: ResultSet.getClob() causing problems when used with JPA's @Lob

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob
Date: 2011-02-10 07:39:19
Message-ID: 4D539627.6060900@officenet.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 02/09/2011 04:23 AM, Lew wrote:
> Andreas Joseph Krogh wrote:
>> I get around this problem in Hibernate by using this combination:
>>
>> @Column(name="my_name")
>> @Lob
>> @Type(type="org.hibernate.type.StringClobType")
>>
>> ...but the StringClobType is deprecated.
>>
>
> It really makes it so much easier to have a TEXT column mapped to a
> 'String'.
>
> @Entity public class Foo
> {
> @Id
> private String ident;
> private String somethingBackedByTEXT;
> ...
> }
>
> FWIW, in a database like Oracle that does have CLOBs it's still a lot
> easier with Hibernate to map CLOBs to 'String' than to 'Clob', as I
> learned from experience. Even the Hibernate documentation recommends
> against mapping to 'Clob'.

Seems you missed the point

My mapping was like this, to a String-property

@Column(name="my_name")
@Lob
@Type(type="org.hibernate.type.StringClobType")
private String someLongDescription;

But I have to use @Lob in order to be able to persist this long String
in Oracle. With PG it works without the @Lob but then it's not portable.
The problem is that Hibernate uses ResultSet.setClob() regardless of the
DB-dialect when it sees @Lob on a String-type. This shouldn't be a
problem is the PG JDBC-driver implemented setClob as setString, but some
think that's not correct.

--
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 | |
------------------------+---------------------------------------------+

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maurin, Marion 2011-02-10 07:50:24 RE : PGXAConnection and autocommit problem
Previous Message rsmogura 2011-02-09 20:13:47 Re: PGXAConnection and autocommit problem