Contain Managed Persistence
Download
Report
Transcript Contain Managed Persistence
Container Managed
Persistence
General Guidelines
Home and Remote interfaces are
implemented the same as for bean
managed persistence
Entity Bean class contains no database
access code
Application Deployment Tool generates
database access statements
Specify container managed fields when
you run the ADT
Rules for Container
Managed Fields
Must be one of the following types
Java primitive
Java serializable class
Reference of a home interface
Reference of a remote interface
Must be ‘public’ and not ‘transient’
One field selected as the primary
key (using the ADT)
Implementing Interfaces
Still have to follow the rules for
implementing methods required by the
interfaces.
Some methods will be empty
EJBLoad() & EJBStore()
Container implements the code
Only need to add stuff to process data if
required by the application.
EJBCreate()
Make your field assignments
Container makes the datbase call once
the bean is created
Implementing Interfaces
(cont)
findByPrimaryKey()
Completely implemented in the
container
findByDescription() and
findInRange()
Mostly implemented
User adds WHERE clause during
deployment (using the ADT).
Here’s a link to Java’s example of
how to do it using the J2EE RI….
http://developer.java.sun.com/developer/onlineTraining/…
EJBIntro/exercises/EntityBean/index.html