Building, Packaging, Deploying, and Running the producermethods Example ............... 564
The producerfields Example: Using Producer Fields to Generate Resources ........................ 565
The Producer Field for the producerfields Example .......................................................... 566
The producerfields Entity and Session Bean ...................................................................... 567
The producerfields Facelets Pages and Managed Bean ..................................................... 568
Building, Packaging, Deploying, and Running the producerfields Example ................. 570
The billpayment Example: Using Events and Interceptors ........................................................ 572
The PaymentEvent Event Class ................................................................................................ 572
The PaymentHandler Event Listener ....................................................................................... 572
The billpayment Facelets Pages and Managed Bean ............................................................ 573
The LoggedInterceptor Interceptor Class ............................................................................ 575
Building, Packaging, Deploying, and Running the billpayment Example ........................ 576
The decorators Example: Decorating a Bean ............................................................................... 578
Components of the decorators Example .............................................................................. 578
Building, Packaging, Deploying, and Running the decorators Example .......................... 579
Part VI Persistence ..........................................................................................................................................581
32 Introduction to the Java Persistence API ...................................................................................... 583
Entities ................................................................................................................................................ 583
Requirements for Entity Classes .............................................................................................. 584
Persistent Fields and Properties in Entity Classes .................................................................. 584
Primary Keys in Entities ............................................................................................................ 589
Multiplicity in Entity Relationships ......................................................................................... 591
Direction in Entity Relationships ............................................................................................. 591
Embeddable Classes in Entities ................................................................................................ 594
Entity Inheritance .............................................................................................................................. 595
Abstract Entities ......................................................................................................................... 595
Mapped Superclasses ................................................................................................................. 595
Non-Entity Superclasses ........................................................................................................... 596
Entity Inheritance Mapping Strategies .................................................................................... 596
Managing Entities .............................................................................................................................. 599
The EntityManager Interface .................................................................................................. 599
Persistence Units ........................................................................................................................ 603
Querying Entities ............................................................................................................................... 604
Contents
The Java EE 6 Tutorial • July 201220