Using JPA’s and Hibernate’s 2nd level cache can improve the performance of your persistence layer. It acts as a session-independent entity store. Hibernate uses it whenever you call the find method on your EntityManager or traverse an association to fetch a cached entity. Instead of executing a database query, Hibernate gets the entity object from

Read More

Lombok is a popular framework among Java developers because it generates repetitive boilerplate code like getter and setter methods, equals and hashCode methods, and the default constructor. All you need to do is add a few annotations to your class and Lombok will add the required code at compile time. This works reasonably well for

Read More

All applications that get deployed to production should use an automated approach to migrate their database. It makes your job a lot easier. It also ensures you don’t miss any changes during the update process. That’s, of course, also true if you develop your application based on Spring Boot. The integration of Flyway and Liquibase

Read More

JPA and Hibernate require you to write lots of Strings. You use them to create ad-hoc and named queries with JPQL, to define native SQL queries and to specify the fetching behavior in an EntityGraph. Until Java 13, the lack of multiline Strings in Java made all of these tasks either annoying to implement or

Read More

A lot of developers complain that Java is too verbose. And I can understand that, especially for all classes that are supposed to be a basic data structure, like JPA/Hibernate entities or DTOs. So, it was no surprise that I got a lot of questions about JDK’s records feature and how you can use it

Read More

Hibernate implements JPA’s standardized constructor expressions and @SqlResultSetMappings to map the results of your queries. And it also supports proprietary ResultTransformers. They provide a powerful and flexible way to map the result of your JPQL, Criteria, and native SQL query to a specific object structure. This can be entity or DTO objects, java.util.List or java.util.Map

Read More

For the last 2 years, I have shared a list of the Java-related YouTube channels that I find the most enjoyable or useful. And based on the popularity of these articles, it seems like I’m not the only one who enjoys watching good lectures and conference talks on YouTube. That’s especially the case in the

Read More

As you might have recognized, thoughts-on-java.org is now thorben-janssen.com. But don’t worry, it’s only a different domain name and nothing really changed. Thoughts-on-java.org gets redirected to thorben-janssen.com, all articles and courses are still there and you can keep all of your bookmarks. I also implemented a small redesign. Well, internally and especially technically, it was a

Read More