Java Reference
In-Depth Information
In the EJB 3.0 specification, the EntityManager class is used to create, find, and
update an entity bean instance. In EJB 3.0, deployment descriptors are not required
and are replaced with metadata annotations. When deployment descriptors are
supplied, their values override annotations. An entity bean is specified with the
@Entity annotation. The table name, column name, and primary key column
properties are specified with the metadata annotations listed in the following table:
Annotation
Description
Annotation Elements
@Table
Specifies the table used for
entity bean persistence.
Name (if the name element is not
specified, the EJB class name is used
as the table name).
@Column
Specifies a column
corresponding to an entity
bean property.
Name, nullable, length, updatable,
and unique.
@Id
Specifies a primary key
column property.
@Transient
Specifies a property that is
not persistent.
EJB Query Language ( QL ) queries in the EJB 2.0 specification are specified with the
<query/> element in the ejb-jar.xml deployment descriptor. EJB QL queries in EJB
3.0 are specified with the metadata annotations @NamedQuery and @NamedQueries ,
which are listed in the following table:
Annotation
Description
Annotation Elements
@NamedQueries
Specifies a group of EJB QL
queries
@NamedQuery
Specifies an EJB QL query
name="query name"
query="SQL query"
The entity bean container-managed relationship (CMR) relationships in EJB 2.0 are
specified with the <ejb-relation/> elements in the ejb-jar.xml deployment
descriptor, and the entity bean CMR relationships in EJB 3.0 are specified in the bean
class. The metadata annotations used to specify the entity bean CMR relationships
are listed in the following table:
Annotation
Description
@OneToMany
One-to-many entity bean CMR relationship.
@OneToOne
One-to-one entity bean CMR relationship.
@ManyToOne
Many-to-one entity bean CMR relationship.
@ManyToMany
Many-to-many entity bean CMR relationship.
Search WWH ::




Custom Search