pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Joseph Krogh <andreak@officenet.no>
To: pgsql-jdbc@postgresql.org
Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob
Date: Thu, 10 Feb 2011 08:39:19 +0100
Message-ID: <4D539627.6060900@officenet.no> (raw)
In-Reply-To: <iit1ap$hqk$1@news.albasani.net>
References: <4D511C79.4010507@opencloud.com>
	<23828143.70.1297164859086.JavaMail.on@prod2>
	<iit1ap$hqk$1@news.albasani.net>

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@officenet.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 |                                             |
------------------------+---------------------------------------------+



view thread (36+ messages)  latest in thread

Message-ID: <4D539627.6060900@officenet.no>
Permalink:  ../4D539627.6060900@officenet.no/
Also on:    postgresql.org/message-id/4D539627.6060900@officenet.no

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: andreak@officenet.no
  Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob
  In-Reply-To: <4D539627.6060900@officenet.no>
  References: <4D511C79.4010507@opencloud.com> <23828143.70.1297164859086.JavaMail.on@prod2> <iit1ap$hqk$1@news.albasani.net> <4D539627.6060900@officenet.no>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox