@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…

Spring Data JPA – Detecting Your Entity’s State

Spring Data JPA – Detecting Your Entity’s State

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…