A Simple Java Persistence API Entity



An Entity is much like a regular Java Bean. It has private properties that can be accessed through public get and set methods,
and can be treated as such (a regular bean). The things that make this ordinary class an Enity are the annotations that enables the bean to be
managed by the EJB container.

This is what a class could look like without the annotations:

This is what a class could look like WITH the annotations:

Ԋ

The @Entity annotation is required to tell the EJB container that this class can be used to store information.

The @Id annotation tells what unique identifier the instance can be selected on. This reflects the primary key in the database.
In the case that the primary key spans multiple columns in the table,
a composite primary key is required and the @Id fields may be replaced by a single field that is annotated @EmbeddedId.







Search for more Java info on this site here:
Custom Search


Any thoughts or questions?