Coffee with Thorben 2020-02-26 – Utility classes that make your life easier


Follow me on YouTube to not miss any new videos.

Join the chat on YouTube.

Utility classes that make your life easier

Implementing a persistence layer with Hibernate can require a lot of String references:

  • You’re referencing entities and their attributes by their name.
  • Query hints have very long names that you need to provide as a String.
  • When registering an entity graph, you need to provide a String that defines if it will be used as a fetch or load graph.

To make working with these Strings a little easier, JPA and Hibernate provide utility classes and code generators. In this stream, we will take a closer look at the most commonly options.

Live Online Workshops

If you enjoyed the live stream, you will love my live online workshops. Find out more at thorben-janssen.com/workshops.

Question of the Week

This week, I answered a question on StackOverflow about how Hibernate handles superclasses if you annotate them with @MappedSuperclass. This mapping is pretty simple but you should be aware of its limitations:

Getting An Instance Of A Mapped Superclass With Hibernate EntityManager.

This week’s tutorials

Blog

The 2 most common mistakes when optimizing your persistence layer’s performance are applying general best practices and following the advice of static code analyzers blindly. And that’s not because all these recommendations are entirely wrong.

It’s because none of them are tailored to your application and the data it manages. A good part of these general recommendations isn’t relevant to your application. Most application-specific issues don’t show up in these lists. So, you’re spending your time fixing problems that don’t provide any value to your users instead of working on the critical ones.

There are better ways to improve the performance of your application. In this week’s post, I talk about the right performance tuning mindset, the information you need, and the actions you can take: Hibernate Performance Tuning Done Right.

YouTube

One of the most important topics when talking about performance optimizations for Spring Data JPA is handling associations. As a rule of thumb, you should always use lazy fetching for all associations and combine it with query-specific fetching.

2 Ebooks 

to boost your Hibernate skills

Sign up below to join my newsletter and to get your free ebooks:

  • Java 8 Support in Hibernate 5
  • Native Queries with Hibernate

I will collect, use and protect your data in accordance with my Privacy policy.

In this week’s video, I show you how to do that using Spring Data JPA. As so often, it makes things a little easier than plain JPA: How to Initialize Entity Associations with Spring Data JPA

Related Articles

Responses

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Black Friday & Launch Offer: Join the Persistence Hub!

Hi and welcome!

To make sure I provide you with the best content, please tell me what you are looking for.