Red Hat APPLICATION SERVER - JONAS Manual page 100

Jonas
Hide thumbs Also See for APPLICATION SERVER - JONAS:
Table of Contents

Advertisement

92
cmp-version 1.x /cmp-version
cmp-field
field-name fieldOne /field-name
/cmp-field
cmp-field
field-name fieldTwo /field-name
/cmp-field
With
container-managed persistence
ing the data in the relational database; this code is included in the container itself (generated by the
platform tools). However, for the EJB platform to know how to access the database and which data to
read and write in the database, two types of information must be provided with the bean:
First, the container must know which database to access and how to access it. To do this, the only
required information is the name of the DataSource that will be used to get the JDBC connection.
For container-managed persistence, only one DataSource per bean should be used.
Then, it is necessary to know the mapping of the bean fields to the underlying database (which table,
which column). For CMP 1.1 or CMP 2.0, this mapping is specified by the deployer in the JOnAS-
specific deployment descriptor. Note that for CMP 2.0, this mapping may be entirely generated by
JOnAS.
The EJB specification does not specify how this information should be provided to the EJB platform
by the bean deployer. Therefore, what is described in the remainder of this section is specific to JOnAS.
For CMP 1.1, the bean deployer is responsible for defining the mapping of the bean fields to the
database table columns. The name of the DataSource can be set at deployment time, since it depends
on the EJB platform configuration. This database configuration information is defined in the JOnAS-
specific deployment descriptor via the
mapping for a CMP 1.1 Entity Bean:
jdbc-mapping
jndi-name jdbc_1 /jndi-name
jdbc-table-name accountsample /jdbc-table-name
cmp-field-jdbc-mapping
field-name mAccno /field-name
jdbc-field-name accno /jdbc-field-name
/cmp-field-jdbc-mapping
cmp-field-jdbc-mapping
field-name mCustomer /field-name
jdbc-field-name customer /jdbc-field-name
/cmp-field-jdbc-mapping
cmp-field-jdbc-mapping
field-name mBalance /field-name
jdbc-field-name balance /jdbc-field-name
/cmp-field-jdbc-mapping
/jdbc-mapping
is the JNDI name of the DataSource object identifying the database.
jdbc_1
name of the table used to store the bean instances in the database.
are the names of the container-managed fields of the bean to be stored in the
mBalance
, and
customer
balance
container-managed persistence
does not exist.
For a CMP 2.0 Entity Bean, only the
the mapping may be generated automatically:
jdbc-mapping
jndi-name jdbc_1 /jndi-name
the programmer need not develop the code for access-
jdbc-mapping
columns of the
accountsample
. For
bean-managed persistence
jndi-name
Chapter 8. Developing Entity Beans
element. The following example defines the
table. This example applies to
element of the
jdbc-mapping
accountsample
,
mAccno
mCustomer
accno
, the database mapping
is mandatory, since
is the
, and
,

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Application server

Table of Contents