Re: ResultSet.getClob() causing problems when used with JPA's @Lob
От | Andreas Joseph Krogh |
---|---|
Тема | Re: ResultSet.getClob() causing problems when used with JPA's @Lob |
Дата | |
Msg-id | 4D539627.6060900@officenet.no обсуждение исходный текст |
Ответ на | Re: ResultSet.getClob() causing problems when used with JPA's @Lob (Lew <noone@lewscanon.com>) |
Список | 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@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 | | ------------------------+---------------------------------------------+
В списке pgsql-jdbc по дате отправления: