Entities
An entity is a domain object that represents a business entity, and correspondingly, a record in a database table. An entity class should satisfy the following requirements:
- The class must be annotated with the
javax.persistence.Entity
annotation. - The class must have a public or protected no-argument constructor. The class may have other constructors.
- The class must not be declared final. No methods or persistent instance variables may be declared final.
- If an entity instance is passed by value as a detached object, such as through a session bean's remote business interface, the class must implement the
Serializable
interface. - Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes.
- Persistent instance variables must be declared private, protected, or package-private and can be accessed directly only by the entity class's methods. Clients must access the entity's state through accessor or business methods.
Entity mapping
One of the fundamental...