Persistence class or Entity class
- Hibernate supports POJO(Plain Old Java Object) as persistence objects.
- The Hibernate persistent objects doesn’t have Hibernate API dependency.
- The persistent object should satisfy the following rules.
- Should support a no-argument constructor.
- It should support java bean style setter and getter methods for the persistent properties, i.e. the properties of this object to be managed by Hibernate.
- If this persistent type is configure with lazy loading, the setter and getter methods should be non-final.
- This wants to implement equals () & hashCode () methods, so that we can manage these objects in to Collections.
Should be a public non final class.
This is required, if we want to configure this persistence type with lazy loading.AS Hibernate creates a dynamic proxy for implementing lazy loading.
This is for the following two reasons.
Hibernate uses CGLIB API to create dynamic proxy for the persistent class, which demands to have no-argument constructor in the super class (i.e. super class of dynamic proxy).
Hibernate uses constructor.newInstance () to create a persistent object.