| Reason is that @Lob with String does result in a CLOB TypeDescriptor which used getClob and setClob calls on the Postgres JDBC Driver - which does the OID mapping and used large objects to store and load the text, imho nothing that Hibernate is doing wrong here or does prefer here, its done from the Driver. You can remap that so that setString and getString is used instead of a Clob like this with a custom dialect if the maximum expected string size does not exceed the text type maximum:
public class PGSQLMapDialect extends PostgreSQL9Dialect {
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
if (Types.CLOB == sqlTypeDescriptor.getSqlType()) {
return LongVarcharTypeDescriptor.INSTANCE;
}
return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
}
|