The best way to use entity inheritance with JPA and Hibernate

Introduction Recently, my friend Lukas Eder wrote the following message on Twitter: Just like in any OOP (Object-Oriented Programming) language, entity inheritance is suitable for varying behavior rather than reusing data structures, for which we could use composition. The Domain Model compromising both data (e.g. persisted entities) and behavior (business logic), we can still make use of inheritance for implementing a behavioral software design pattern. In this article, I’m going to demonstrate how to use JPA inheritance as a means to implement the Strategy design pattern.

The Builder pattern and the Spring framework

Introduction In this article, we are going to see how we can use the Builder pattern when creating beans with the Spring framework. I like to make use of the builder pattern whenever an object has both mandatory and optional properties. But building objects is usually the Spring framework responsibility, so let’s see how you can employ it using both Java and XML-based Spring configurations.