Hibernation column transformer

I am new to Hibernate. I have a use case when I need to apply a transformer (encrypt / encode) to a constant member of a class just before saving it and (decrypt / decode) after loading the data. I look something like this:

public class PersistentClass {

    @Encrypt(transformer=DoubleTransformer)
    public Double dataToBeEncoded;

    public Double persistAsIs;
}

All of my transformers lead to text data that will be stored in db, and I want to define the transformers once and reuse it in all constant classes. Is there an easy way to do this?

+1
source share
1 answer

, : JPA . Pre-Persist, Pre-Update Post-Load.

+2

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


All Articles