Skip to main content

Posts

Showing posts from March, 2018

Hibernate Features

@MappedSuperclass This annotation can be used when you want to create inheritance in the Entities. Entities may inherit from superclasses that contain persistent state and mapping information but are not entities. That is, the superclass is not decorated with the  @Entity  annotation and is not mapped as an entity by the Java Persistence provider. These superclasses are most often used when you have state and mapping information common to multiple entity classes. Mapped superclasses are specified by decorating the class with the annotation  javax.persistence.MappedSuperclass : @MappedSuperclass public class Employee { @Id protected Integer employeeId; ... } @Entity public class FullTimeEmployee extends Employee { protected Integer salary; ... } @Entity public class PartTimeEmployee extends Employee { protected Float hourlyWage; ... } Mapped superclasses cannot be queried and can’t be used in  EntityManager  or  Query  operations. You must use ent