PostgreSQL problem when using @Lob on String field

Description

After upgrading from 3.5.6 to 3.6 we ran into issues using @Lob on String fields previously mapping to PostgreSQL's TEXT type. When loading these fields the PostgreSQL driver returns a:

"org.postgresql.util.PSQLException: Bad value for type long: Text content..."

The problem can be traced to Hibernates ClobTypeDescriptor which calls a resultSet.getClob("lobfield"). Apparently it expects an OID pointing to a clob and not the text field.

I found a lengthy discussion on this subject here:

http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/8385d700bf9ae6d1/0855172bb7ce5d43

At the bottom of the discussion a workaround is mentioned. Using @Type(type="org.hibernate.type.StringClobType") on the @Lob String fields gets things working as before, but this is a deprecated solution.

Environment

postgresql:8.3-606.jdbc3

Activity

Show:
Gail Badner
August 16, 2011, 9:10 PM

This is expected behavior.

Mike Noordermeer
November 23, 2012, 5:52 PM

Thanks Gail, really helpful. What you're basically saying, is that it is expected behaviour for Hibernate to not be able to read from it's own, self-generated schema when using Postgres...

Endrigo Antonini
January 26, 2013, 9:08 PM

I know this is an old issue. But I'm facing this problem right now.

What happens if I add this @Type on the column and changed the database?
Stop using PostgreSQL to use MySQL, or MSSQL?
I would have to remove that source?

I'm asking this because I'm having the opposite problem. I was using a self-generated database using MSSQL than the company decided to use a PostgreSQL server, so what I did? I just changed the Dialect, connection variables and, on my happy thought, it would work just as it supposed to.
But what I saw is that I’ll have to change all my source code to add this annotation @Type. Then I ask you, And if my company decide to use other database than Postgre? And if some customer decides to use other database then the Postgre? I would have to create different versions of the product to each database?

Vladimir Loshchin
March 26, 2013, 10:06 AM

Reporduce this bug in Hibernate 4.x. It worked fine in 3.4.x version, but now it doesn't. This is expected behaviour? Really?..

Brett Meyer
March 7, 2014, 5:30 PM

Bulk closing rejected tickets in "resolved" state.

Assignee

Gail Badner

Reporter

RoelofJ

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure