Spring Data JPA’s repositories provide many methods that implement the standard operations you need to create a basic persistence layer. One of them is the save(S entity) method, which the CrudRepository defines. When you call this method, it depends on the entity object’s state which database operation Spring Data JPA performs. Spring Data JPA stores a new

Read More

QueryDSL is a popular framework that provides you a Java API to create queries for relational databases and other data stores. If you’re familiar with JPA’s Criteria API, you might think that it does the same as QueryDSL and that you don’t need to learn about another framework. But I recommend you give QueryDSL a

Read More

Database administrators often use views to combine, transform and present data in a form that’s easy to process and query by the application. They are easier to maintain and optimize than a complex query statement that’s developed and maintained in one or more applications. Using Spring Data JPA, you can map and query views in

Read More

Hibernate and the JPA specification define multiple generators to create unique primary key values. An obvious question when learning about these generators is if you can apply them to basic attributes as well. Unfortunately, the answer is no. But Hibernate’s ValueGenerator provides an easy-to-use alternative. As I will show you in this article, you can

Read More

Panache is a Quarkus-specific library that handles most of the boilerplate code usually required by JPA-based persistence layers. One of the features it provides is ready-to-use and easily customizable repositories for your entity classes. Repositories are a very popular pattern for Java-based persistence layers. They encapsulate the database operations you can perform on entity objects

Read More

With Spring Data JPA, you can use more features than just the ones defined by the JPA specification. It acts as a layer on top of a persistence provider, e.g., Hibernate. This provider implements the JPA specification and provides a set of proprietary features. Due to this multi-layer architecture, you can use all standard JPA

Read More

The main idea of the active record pattern is to let the entity object encapsulate the data and the database operations you can perform on it. That makes it an excellent fit for the persistence layer of a Java application. Panache, a Quarkus extension based on Hibernate, provides great support for this pattern and makes

Read More

When using Spring Data JPA, you are used to derived and custom queries that return the result in your preferred format. A typical example is a DTO projection, which is the most efficient one for read-only operations. To use it in a derived or custom JPQL query, you only need to change the return type

Read More