A MappedSuperclass uses inheritance for field and code reuse.
In addition we leverage some composition via Embeddable feature provided Hibernate
@Embeddable
public class Department {
private long deptId;
private String name;
private String description;
}
@Entity
@Table(name="CSE_DEPT", schema="test")
public class CSEDepartment{
@Embedded
private Department dept;
}
What is difference between @MappedSuperclass and @Embeddable and what is appropriate situation where they use.