How to activate Hibernate Statistics to analyze performance issues
|

How to activate Hibernate Statistics to analyze performance issues

Did you ever ask yourself why a server request took ages on the production system while your local test system was just fine?Well, we all had these situations, and we will have several more of them in the future. In my experience, strange performance drops are often related to slow database queries. But which query…

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…

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…