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…

How to call custom database functions with JPA and Hibernate
| |

How to call custom database functions with JPA and Hibernate

JPA supports a set of database functions which you can use to perform small operations and transformations within a query. This is often easier and faster than doing it in the Java code. But how do you call functions which are not supported by the JPA standard, like database-specific ones or the custom functions implemented…

|

Free Sample Lecture: Hibernate 1st Level Cache

I’m currently recording the Hibernate Performance Tuning Online Training and today I want to share the lecture about Hibernate’s 1st level cache with you. Hibernate activates the 1st level cache by default and uses it to optimize the performance of your application if you don’t prevent it. OK, you probably wonder why you should prevent Hibernate from using the cache…

| | |

Free Mini Course: How to find and fix n+1 select issues with Hibernate

Loading related entities with JPA and Hibernate is a comfortable feature that is also the most common reason for performance issues. In most applications you can find one of these two issues: related entities are eagerly loaded, even if they are not needed or related entities are lazily loaded which creates n+1 select issues if…

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…