Java Reference
In-Depth Information
mapping information. If you want to use the Hibernate tools to generate your database
schema, you must compile your entity classes containing their annotations first.
The full set of persistence annotations available in the EJB 3 API is listed in Table 6-1. In
this section, we are going to introduce the significant core of these annotations alongside a
simple set of classes to illustrate how they are applied.
Table 6-1. The EJB 3 Annotations
Attribute Name
Target
Purpose
AttributeOverride /
T, M, and F
Overrides the default column details of embedded
AttributeOverrides
(component) entities.
Basic
M and F
Overrides the default fetch strategy and nullability
of basic fields and properties.
Column
M and F
Associates a field or property of the class with a col-
umn in the mapped table.
ColumnResult
Used as a parameter of the @SqlResultSetMapping
annotation; permits the fields of an entity to be
returned as columns in a conventional JDBC
ResultSet .
Pm
DiscriminatorColumn
T
Overrides the default behavior of the discriminator
column in single or joined table inheritance strate-
gies.
DiscriminatorValue
T
Determines the value associated with the entity in
the discriminator column of the root of the entity's
inheritance hierarchy.
Embeddable
T
Marks an entity as being an embeddable (compo-
nent) entity.
Embedded
M and F
Marks a field or property as consisting of an embed-
ded (component) entity.
EmbeddedId
M and F
Marks a primary key field as consisting of an
embedded (component) entity. This is mutually
exclusive with the @Id annotation.
Entity
T
Identifies an entity and allows attributes, such as its
name, to be overridden from the defaults.
EntityListeners
T
Allows appropriate javax.persistence.
EntityListener classes to be invoked during the life
cycle of the marked entity.
EntityResult
Used as a parameter of the @SqlResultSetMapping
annotation; permits the fields of an entity to be
returned as columns in a conventional JDBC
ResultSet .
Pm
Enumerated
Defines a field or property as being an enumerated
type.
M and F
ExcludeDefaultListeners
Prevents the default EntityListener s from being
invoked during the life cycle of the marked entity.
T
ExcludeSuperclassListeners
Prevents the EntityListener s of the superclass from
being invoked during the life cycle of the marked
entity.
T
Continued
Search WWH ::




Custom Search