@DiscriminatorFormular – Modeling Single Table Inheritance Without a Discriminator

@DiscriminatorFormular – Modeling Single Table Inheritance Without a Discriminator

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…

Modeling sequence-based composite primary keys with Hibernate

Modeling sequence-based composite primary keys with Hibernate

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…

How to Generate Values of Basic Entity Attributes with Hibernate

How to Generate Values of Basic Entity Attributes with Hibernate

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…