12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Setting Properties<br />

into a BLOB. The Container does not do any “smart” mapping on these classes or types;<br />

it just stores the state in binary format. The Container's CMP engine observes the<br />

following rule: the engine serializes as a BLOB all types that are not one of the explicitly<br />

supported types.<br />

In this context, the Container follows the JDBC specification: a BLOB is the type to which<br />

LONGVARBINARY maps. (For Oracle, this is LONG RAW.)<br />

Using SQL keywords<br />

The CMP engine for the <strong>Borland</strong> Container can handle all SQL keywords that comply<br />

with the SQL92 standard. However, you should keep in mind that vendors frequently<br />

add their own keywords. For example, Oracle uses the keyword VARCHAR2. If you want<br />

to ensure that the CMP engine can handle vendor keywords that may differ from the<br />

SQL standard, set up an environment property in the deployment descriptor that maps<br />

the CMP field name to the column name. By using this sort of environment property,<br />

you do not have to modify your code.<br />

For example, suppose you have a CMP field called “select”. You can use the following<br />

environment property to map “select” to a column called “SLCT”, as shown below.<br />

<br />

<br />

Data<br />

<br />

select<br />

SLCT<br />

<br />

<br />

<br />

Using null values<br />

It is possible that your database values can contain SQL null values. If so, you must<br />

map them to fields whose Java data types are permitted to contain Java null values.<br />

Typically, you do this by using Java types instead of primitive types. Thus, you use a<br />

Java Integer type rather than a primitive int type, or a Java Float type rather than a<br />

primitive float type.<br />

Establishing a database connection<br />

You must specify a DataSource so that the CMP engine can open a database<br />

connection. The DataSource defines the information necessary for establishing a<br />

database connection, such as username and password. Define a DataSource and then<br />

use a resource-ref to refer to the DataSource in the XML deployment descriptor for the<br />

bean. The CMP engine can then use the DataSource to access the database via<br />

JDBC.<br />

At the point in the vendor-specific XML file where you provide the jndi binding for the<br />

resource-ref, add the element<br />

True<br />

For cases where the entity bean declares only one resource-ref, you do not need to<br />

provide the above XML element. When the entity bean has only one resource-ref, the<br />

<strong>Borland</strong> Container knows to automatically choose that one resource as the cmpresource.<br />

Container-created tables<br />

You can instruct the <strong>Borland</strong> EJB Container to automatically create tables for<br />

container-managed entities based on the entity's container-managed fields. Because<br />

table creation and data type mappings vary among vendors, you must specify the<br />

JDBC database dialect in the deployment descriptor to the Container. For all<br />

122 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!