Java Reference
In-Depth Information
An <entity> entry in the structural section defines the makeup of the entity bean. The struc-
tural information for our Quote Bean is listed in the following code snippet:
<entity>
<description>
Describes a persistent quote.
</description>
<ejb-name>Quote</ejb-name>
<home>QuoteHome</home>
<remote>Quote</remote>
<ejb-class>QuoteBean</ejb-class>
<prim-key-class>QuotePk</prim-key-class>
<persistence-type>Container</persistence-type>
<reentrant>False</reentrant>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>customerName</field-name></cmp-field>
<cmp-field><field-name>phoneNumber</field-name></cmp-field>
<cmp-field><field-name>loanAmount</field-name></cmp-field>
<cmp-field><field-name>monthlyPayment</field-name></cmp-field>
<cmp-field><field-name>nterestRate</field-name></cmp-field>
</entity>
There are a couple of additions here. The first is the declaration of the primary key class. Just
like the other class declarations, this is the fully qualified Java classname for the primary key
class.
The entry for persistence type must be present and specified whether the given entity bean's
persistence is container-managed or bean-managed. We discussed the difference between these
two in the earlier section, “Who Handles the Persistence?” The two possible values of for this
entry are Container and Bean .
Because you have decided to let the container manage the persistence for the Quote bean, you
must tell the container which fields in the entity bean it is required to manage. Each of these
attributes is declared inside the container-managed persistence entry, <cmp-field> . If you
remember, each of these attributes was declared as public in the bean class so that the con-
tainer has access to it.
A concept that we have not discussed yet is reentrance . The Quote Bean is defined as non-
reentrant by specifying the false value for the <reentrant> tag. Reentrance defines whether
the entity bean can be looped back into during the same execution context. An example of
reentrance would be: A client makes a call to entity bean A, bean A then invokes a method in
bean B, and bean B tries to invoke a method in bean A and reenter it. When developing beans
deployed to enable reentrance, take this multithreading into consideration. If reentrance is
denied in the deployment descriptor, an exception will be thrown if the system tries to reenter
an object.
Search WWH ::




Custom Search