Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4F27D133616B for ; Thu, 10 Feb 2011 03:39:32 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 48038-07 for ; Thu, 10 Feb 2011 07:39:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ns1.officenet.no (unknown [195.159.87.244]) by mail.postgresql.org (Postfix) with ESMTP id 7885A1337B47 for ; Thu, 10 Feb 2011 03:39:24 -0400 (AST) Received: from [79.161.204.50] (helo=[192.168.0.172]) by ns1.officenet.no with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1PnR7X-0004iE-JY for pgsql-jdbc@postgresql.org; Thu, 10 Feb 2011 08:39:22 +0100 Message-ID: <4D539627.6060900@officenet.no> Date: Thu, 10 Feb 2011 08:39:19 +0100 From: Andreas Joseph Krogh Organization: OfficeNet AS User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob References: <4D511C79.4010507@opencloud.com> <23828143.70.1297164859086.JavaMail.on@prod2> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201102/60 X-Sequence-Number: 21458 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 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 | | ------------------------+---------------------------------------------+