| I have a Payload entity with a byte[] field that is annotated with @Lob. Upon lazy initialization, it is treated as a PrimitiveByteArrayTypeDescriptor rather than a BlobTypeDescriptor, which leads to the byte[] being turned into a String (https://hibernate.atlassian.net/browse/HHH-12370). A BlobTypeDescriptor would correctly not try to log the contents of the byte[].
@Entity
public class Payload {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Lob
@Column(length = Integer.MAX_VALUE)
private byte[] payload;
public Payload() {}
public Payload(byte[] payload){
super();
this.payload = Arrays.copyOf(payload, payload.length);
}
public byte[] getPayload() {
return payload;
}
public void setPayload(byte[] payload) {
this.payload = Arrays.copyOf(payload, payload.length);
}
}
However, looking at the database table definition, it is correctly identified as a BLOB:
$ db2 "describe table payload"
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID SYSIBM BIGINT 8 0 No
PAYLOAD SYSIBM BLOB 2147483647 0 Yes
Is there something I am missing about how to get Hibernate to recognize it as a blob type? |