I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea".
My enity code is below,
@ColumnTransformer(
forColumn="test",
read="pgp_sym_encrypt(test::bytea, 'mySecretKey')",
write="pgp_sym_decrypt(?, 'mySecretKey')")
private String test;
When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query.
"test": "\\xc30d04070302474627ea0994ea657bd24401aaa5543862d57524a407e5dbe2ee0f6f0f33ea4f4474f5bc801dca5d32956d41a975505b12ac000f124177bdc2f4507cbfd724d716aaa513ba46f004dfefd3b2b32eb6"
- When I am trying to persist the entity, I am getting the below error.
ERROR: column "test" is of type bytea but expression is of type character varying