@MappedSuperclass – Detailed Description:
@MappedSuperclass
is a JPA annotation used to define a base class that is not directly mapped to its own database table. Instead, its fields and mappings are inherited by entity subclasses that are mapped to tables.
It’s commonly used to share common fields like IDs, audit columns (createdDate, updatedBy), or business logic across multiple entities without duplicating code.
The main idea is to provide a reusable superclass with common persistent properties, so all child entities automatically include those fields in their own tables.
✔️ Avoids Code Duplication
✔️ Centralized Maintenance
✔️ Flexible Data Modeling
✔️ Improves Readability and Organization
✔️ Promotes DRY (Don’t Repeat Yourself) Principle
✔️ Easier to Enforce Standards
✔️ Integrates Seamlessly with JPA/Hibernate