Java Reference
In-Depth Information
?1 ]]>
An EJB 3.0 entity bean is a POJO class annotated with the @Entity annotation. The
finder methods are specified in the entity bean class itself using the @NamedQuery
annotation. The EJB 3.0 entity bean persistence annotations are defined in the javax.
persistence package. Some of the EJB 3.0 persistence annotations are presented in
the following table:
Annotation Description
@Entity Specifies an entity bean.
@Table Specifies the entity bean table.
@SecondaryTable Specifies a secondary table for an entity class for which data is stored
across multiple tables.
@Id Specifies an identifier property.
@Column Specifies the database table column for a persistent entity bean property.
@NamedQueries Specifies a group of named queries.
Specifies a named query or a query associated with a finder method.
Specifies a one-to-many CMR relationship.
Specifies a one-to-one CMR relationship.
Specifies a many-to-many CMR relationship.
The EJB 3.0 entity bean class corresponding to the EJB 2.x entity bean class is annotated
with the metadata annotation @Entity . The finder method findByJournal in the EJB
2.x bean class is specified in the EJB 3.0 POJO class with the @NamedQuery annotation.
The @Id annotation specifies the identifier property catalogId . The
@Column annotation specifies the database column corresponding to the identifier
property catalogId . If a @Column annotation is not specified for a persistent entity
bean property, the column name is the same as the entity bean property name.
Transient entity bean properties are specified with the @Transient annotation. The
EJB 3.0 entity bean POJO class corresponding to the EJB 2.x entity bean is listed next:
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.Id;
import javax.persistence.Column;
@NamedQuery(name = "findByJournal", queryString = "SELECT DISTINCT
OBJECT(obj) FROM Catalog obj WHERE obj.journal = ?1")
public class CatalogBean {
public CatalogBean() {
Search WWH ::

Custom Search