Skip to main content

Implement a JPA attribute converter

Greetings!

Using JPA we can easily map our column values to Java variable and so forth. What if we want our column to have some value and mapped variable has another? One way to achieve this is to have a another method to convert the values.

JPA comes with a another handy way to fulfill this. That is AttributeConverter.
Only thing we want to do is to implement AttributeConverter and add our logic.

Here is an example using Enums.

Comments