Efficient Data Modeling: Hibernate Strategies for Shared Columns

Introduction In database tables, common columns are often used to store metadata about entries, serving purposes such as auditing, multi-tenancy, and soft deletion. These common columns may include information like created_by, updated_by, created_at, and last_modified_at. While it’s possible to duplicate these columns in entity objects, there’s a more efficient way to handle this. Let’s explore that. Scenario Consider a scenario where a set of resource tables shares common columns, such as created_at and last_modified_at. When mapping these tables to (javax.persistence) entities, we notice that all entity classes have common fields like created_at and last_modified_at. ...

April 21, 2021 Β· 2 min Β· 371 words Β· Akash Chandwani