Open JPA equivalent for Hibernate @ColumnTransformer

I am switching the ORM structure from Hibernate to OpenJPA.

In Hibernate, we could annotate the field with @ColumnTransformer, as shown below.

@Column(name = "EMP_NAME", length = 4000)
@ColumnTransformer(
        read = "pgp_pub_decrypt(emp_name::bytea,dearmor('"+key1+"'))",
        write = "pgp_pub_encrypt(?, dearmor('"+key2+"'))"
)
private String empName;

How to do the same in OpenJPA

+4
source share
1 answer

I'm not sure about the specific capabilities of OpenJPA related to this, but the following two alternatives will work for all JPA providers:

  • Create an updatable view that performs the necessary transformations and maps the entity to a view instead of a table.
  • .

, SQL.

+2

Source: https://habr.com/ru/post/1651110/


All Articles