I'm trying to encrypt a byte[] field with jasypt.
My code before encryption
@Entity
public class ContentFile {
...
@Column(name = "fileContent")
@Lob
private byte[] fileContent;
...
}
Normally this gets mapped in the db to BLOB in oracle and h2 which I use. Now after adding encryption I have something like this
@TypeDef(name = TypeDefName.ENCRYPTED_BYTE_ARRAY, typeClass = EncryptedBinaryType.class, parameters = { @Parameter(name = TypeDefParamName.ENCRYPTOR_REGISTERED_NAME, value = EncryptorRegisteredName.HIBERNATE_BINARY_ENCRYPTOR) })
@Entity
public class ContentFile {
...
@Type(type = TypeDefName.ENCRYPTED_BYTE_ARRAY)
@Column(name = "fileContent")
@Lob
private byte[] fileContent;
...
}
But the generated schema is now different - I get RAW(255) in Oracle and Binary(255) in H2, and of course this produces errors since the byte array is much bigger. Looks like @Lob is ignored when @Type is put, so is there a way to tell jasypt/hibernate that this byte[] should be in fact a BLOB?