How to join unassociated entities with JPA and Hibernate
| |

How to join unassociated entities with JPA and Hibernate

Representing associations between entities as attributes is one of the most comfortable and popular features of JPA and Hibernate. It makes it very easy to navigate from one entity to one or more associated entities in your Java code, like from a Person entity to the corresponding Address entity. You can also use the association…

Unsynchronized PersistenceContext – How to model conversations with JPA
| |

Unsynchronized PersistenceContext – How to model conversations with JPA

Most Java EE applications are stateless and there are good reasons for it. But not all user interactions can be implemented in that way. Sometimes you need to model a conversation that consists of multiple steps, like the typical shopping cart or complex update operations. Doing this with JPA 2.0 always felt a little bit…

Create type-safe queries with the JPA static metamodel
|

Create type-safe queries with the JPA static metamodel

When you write a criteria query or create a dynamic entity graph, you need to reference the entity classes and their attributes. The quickest and easiest way is to provide the required names as Strings. But this has several drawbacks, e.g. you have to remember or look-up all the names of the entity attributes when you write the query….