Things are constantly changing, and that’s especially the case in our profession. New frameworks become popular, existing frameworks adapt, and our customers expect us to solve technical and business requirements we’ve never seen before. And that’s, of course, not only the case for software projects. It’s also the case for professional education and a website

Read More

DTO projections provide better performance than entities if you only want to read but not change the retrieved information. They avoid the management overhead of an entity class and enable you to only select the database columns your business code needs. But as so often, DTO projections also have a downside, and that’s the handling

Read More

Inheritance is one of the key concepts of all object-oriented programming languages. And Java makes there no difference. All developers are familiar with this concept and expect to use it in all parts of their code. That, of course, also includes the persistence layer and the entity model. But the concept of inheritance doesn’t exist

Read More

Some primary keys consist of more than 1 entity attribute or database column. These are called composite primary keys. They often contain a foreign key reference to a parent object or represent a complex natural key. Another reason to use composite keys is combining a domain-specific value with a simple counter, e.g., an order type

Read More

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