5 ways to initialize lazy associations and when to use them
| |

5 ways to initialize lazy associations and when to use them

Lazy loading of associations between entities is a well established best practice in JPA. Its main goal is to retrieve only the requested entities from the database and load the related entities only if needed. That is a great approach if you only need the requested entities. But it creates additional work and can be…

| | |

Testing with Aliens: How to test a JPA Attribute Converter with Arquillian

This post was written together with Aslak Knutsen (@aslakknutsen). JPA Attribute Converters provide an easy way to define how an entity attribute gets persisted to the database. You can use them to implement lots of different features, e.g. to encrypt your data as I showed in a previous post: How to use a JPA Attribute Converter…

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 Entity Graphs: How to Dynamically Define and Use an EntityGraph
| |

JPA Entity Graphs: How to Dynamically Define and Use an EntityGraph

This is my second post on Entity Graphs. The first post described the usage of named entity graphs. These can be used to define a graph of entities and/or attributes at compile time that shall be fetched with a find or query method. Dynamic entity graphs do to the same but in a dynamic way. This…