user manual

Chapter 14: Entity Beans and CMP 1.1 in Borland Enterprise Server 145
Setting Properties
For example, suppose you have a CMP field called "select". You can use the
following environment property to map "select" to a column called "SLCT", as
shown below.
<cmp-info>
<database-map>
<table>Data</table>
<column-map>
<field-name>select</field-name>
<column-name>SLCT</column-name>
</column-map>
</database-map>
</cmp-info>
Using null values
It is possible that your database values can contain SQL null values. If so, you
must map them to fields whose Java data types are permitted to contain Java
null values. Typically, you do this by using Java types instead of primitive
types. Thus, you use a Java Integer type rather than a primitive int type, or a
Java Float type rather than a primitive float type.
Establishing a database connection
You must specify a DataSource so that the CMP engine can open a database
connection. The DataSource defines the information necessary for
establishing a database connection, such as username and password. Define
a DataSource and then use a resource-ref to refer to the DataSource in the
XML deployment descriptor for the bean. The CMP engine can then use the
DataSource to access the database via JDBC.
At the point in the vendor-specific XML file where you provide the jndi binding
for the resource-ref, add the element
<cmp-resource>True</cmp-resource>
For cases where the entity bean declares only one resource-ref, you do not
need to provide the above XML element. When the entity bean has only one
resource-ref, the Borland Container knows to automatically choose that one
resource as the cmp-resource.
Container-created tables
You can instruct the Borland EJB Container to automatically create tables for
container-managed entities based on the entity's container-managed fields.
Because table creation and data type mappings vary among vendors, you
must specify the JDBC database dialect in the deployment descriptor to the
Container. For all databases (except for JDataStore) if you specify the dialect,
then the Container automatically creates tables for container-managed entities
for you. The Container will not create these tables unless you specify the
dialect.