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


Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">