In this part of the article, we concentrate on creating entity bean.
Java Persistence requires an entity bean to have two pieces of metadata: @javax.persistence.Entity to tell the EJB container to map the class to the database table and @javax.persistence.Id, the primary key of the table. By default, the persistence provider assumes name-to-name and type-to-type mapping of the fields to database columns. The table name is also the same as the unqualified name of the entity bean class unless specified by the name() attribute.
There are two ways of applying @Id annotation: Java Bean style - mark on setter and getter methods or on each field. In either case, the provider will assume the following methods or fields are also persistent properties. As usual, XML mapping is also available if you prefer.