"Bad value for type long" failure when reading text data from PostgreSQL via Hibernate
Issue
-
A PostgreSQL
text
column is mapped as aLob
property in a Hibernate entity@Lob private String textData;
-
When loading entity rows from the database an exception is encountered:
... org.postgresql.util.PSQLException: Bad value for type long : some text data at org.postgresql.jdbc.PgResultSet.toLong(PgResultSet.java:2861) at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2072) at org.postgresql.jdbc.PgResultSet.getClob(PgResultSet.java:474) at org.postgresql.jdbc.PgResultSet.getClob(PgResultSet.java:460) at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$1.doExtract(ClobTypeDescriptor.java:44) at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238) ...
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
- Hibernate 5
- PostgreSQL
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.