Details
-
tag is here;
-
changes are listed here (or, for people without a Hibernate Jira account, here);
-
release bundles are at SourceForge and BinTray.
For information on consuming the release via your favorite dependency-management-capable build tool, see https://hibernate.org/orm/downloads/
Changes to how Clob values are processed using PostgreSQL81Dialect and its subclasses
A breaking change was made in how Clob values are processed using PostgreSQL81Dialect and its subclasses. The following is copied from the migration guide.
Up to and including 5.2.8, Clob
values and values for String
, character[]
, and Character[]
attributes that are
annotated with @Lob
were:
-
bound using
Clob
representations of the data (usingPreparedStatement#setClob
orCallableStatement#setClob
); -
retrieved as
Clob
values (usingResultSet#getClob
orCallableStatement#getClob
), which were converted to the appropriate Java type; -
stored as PostgreSQL Large Objects; i.e., an
OID
for the value is stored in atext
column, which refers to the actual data stored in a different (PostgreSQL-specific) table.
In 5.2.9 and 5.2.10, due to the fix for HHH-11477, Clob
values and values for String
, character[]
, and Character[]
attributes that are annotated with @Lob
were:
-
bound using
String
representations of the data (usingPreparedStatement#setString
orCallableStatement#setString
); -
retrieved as
String
values (usingResultSet#getString
orCallableStatement#getString
), which were converted to the appropriate Java type; -
stored as variable-length character strings.
As a consequence of these changes, data persisted using a version of Hibernate prior to 5.2.9 cannot be read using 5.2.9 or 5.2.10. Data persisted using Hibernate 5.2.9 or 5.2.10 can no longer be read using 5.2.11 or later.
A workaround that can be used in 5.2.9 and 5.2.10 that will restore the 5.2.8/5.2.11 behavior is to override the PostgreSQL dialect with:
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
if( sqlCode == Types.CLOB ){
return ClobTypeDescriptor.CLOB_BINDING;
}
return super.getSqlTypeDescriptorOverride( sqlCode );
}
In addition, any Clob
values and values for String
, character[]
, Character[]
attributes that are annotated with
@Lob
that were stored as variable-length character strings using 5.2.9 or 5.2.10 should be updated to store the values
as PostgreSQL Large Objects before migrating to 5.2.11.
For example, if variable-length character strings were stored by 5.2.9 or 5.2.10 for the following mapping:
@Entity(name = "TestEntity")
@Table(name = "TEST_ENTITY")
public static class TestEntity {
@Id
@GeneratedValue
private long id;
@Lob
String firstLobField;
@Lob
String secondLobField;
@Lob
Clob clobField;
...
}
the variable-length character strings can be converted to PostgreSQL Large Objects by executing the following SQL:
update test_entity
set clobfield = lo_from_bytea( 0, cast( clobfield as bytea ) ),
firstlobfield = lo_from_bytea( 0, cast( firstlobfield as bytea ) ),
secondlobfield = lo_from_bytea( 0, cast( secondlobfield as bytea ) )