Hibernate provides 2 proprietary features that enable you to define additional filter criteria that Hibernate applies to every query that selects a specific entity class. This article will show you how to use the @FilterDef and @Filter annotations, which is the more flexible approach. You can activate and deactivate filter definitions for your current session

Read More

Hibernate Envers is a popular library that automates the creation of an audit log. As I’ve shown in previous articles, it logs all write operations performed using your entity classes in an audit log and provides a flexible API to query data from that log. Based on these articles, I got recently asked if Hibernate

Read More

JPA and Hibernate make it very easy to model associations between entities. You can model associations between 2 concrete classes or model a polymorphic association to an inheritance hierarchy. These mappings are more than sufficient for almost all of your association mappings. But sometimes, you might want to model a polymorphic association to independent entity

Read More

One of the common questions when analyzing a slow application is if there are any slow database queries. You can, of course, monitor these queries on your database. But then you still need to match them with a part of your Java code. And because there is no easy way to see what happened immediately

Read More

Join the chat on YouTube. Contents1 Natural vs Surrogate Primary Keys2 New Course: Spring Data JPA3 Question of the Week4 This week’s tutorials4.1 Blog4.2 YouTube Natural vs Surrogate Primary Keys When modeling your entity classes and database tables, you need to decide what kind of primary key you want to use. You can use a

Read More

Before Spring Boot, you had to do quite a few things to set up Spring Data JPA. You not only had to annotate your entity classes with mapping annotations, add a dependency to Spring Data JPA and configure your database connection. You also had to enable repositories and transaction management and configure your EntityManagerFactory. That

Read More

Join the chat on YouTube. Contents1 Utility classes that make your life easier2 Live Online Workshops3 Question of the Week4 This week’s tutorials4.1 Blog4.2 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

Read More

Optimizing the performance of your application is a complex and application-specific task. All domain models are different, and often enough, the amount of data managed by them also differs significantly between multiple installations. In addition to that, almost all performance tuning techniques have trade-offs, which don’t make them a great fit for all situations. Because

Read More