How to use a JPA Attribute Converter to encrypt your data
|

How to use a JPA Attribute Converter to encrypt your data

A few days ago, I read an interesting article by Bear Giles about Database encryption using JPA listeners from 2012. He discusses his requirements for an encryption solution and provides a code example with JPA listeners. His main requirements are: provide transparent encryption that does not affect the application, be able to add the encryption…

JPA Attribute Converter – The better way to persist enums
|

JPA Attribute Converter – The better way to persist enums

JPA provides 2 standard mappings for enums, but both have serious downsides. Using the @Enumerated annotation, you can use EnumType.ORDINAL or EnumType.STRING to map the enum value to its database representation. The ordinal of an Enum depends on the ordering of its values and can create problems if we need to add new ones. The…