JPA Entity Graphs: How to Define and Use a @NamedEntityGraph
| |

JPA Entity Graphs: How to Define and Use a @NamedEntityGraph

Lazy loading is often an issue with JPA. You have to define at the entity if you want to use FetchType.LAZY (default) or FetchType.EAGER to load the relation and this mode is always used. FetchType.EAGER is only used if we want to always load the relation. FetchType.LAZY is used in almost all of the cases…

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…

Criteria Update/Delete – The easy way to implement bulk operations with JPA2.1
| |

Criteria Update/Delete – The easy way to implement bulk operations with JPA2.1

JPA 2.1 added a list of nice features to the specification. One of them is the support for bulk update and delete operations in the Criteria API. We will have a look at the new CriteriaUpdate and CriteriaDelete classes in this article. If you like to learn more about the other features added in JPA 2.1, have…