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.

Container-Managed Persistence in <strong>Borland</strong> Enterprise Server<br />

ORDER_NUMBER<br />

<br />

<br />

line<br />

LINE<br />

<br />

<br />

<br />

Mapping one field to multiple columns<br />

Many users may employ coarse-grained entity beans that implement a Java class to<br />

represent more fine-grained data. For example, an entity bean might use an Address<br />

class as a field, but may need to map elements of the class (like AddressLine1,<br />

AddressCity, and so forth) to an underlying database. To do this, you use the <br />

element, which defines a field map between your fine-grained class and its<br />

underlying database representation. Note that such classes must implement<br />

java.io.Serializable and all their data members must be public.<br />

Consider an entity bean called Customer that uses the class Address to represent a<br />

customer's address. The Address class has fields for AddressLine, AddressCity,<br />

AddressState, and AddressZip. Using the following XML, we can map the class to its<br />

representation in a database with corresponding columns:<br />

<br />

Customer<br />

.<br />

.<br />

<br />

<br />

Address<br />

<br />

Address.AddressLine<br />

STREET<br />

<br />

<br />

Address.AddressCity<br />

CITY<br />

<br />

<br />

Address.AddressState<br />

STATE<br />

<br />

<br />

Address.AddressZip<br />

ZIP<br />

<br />

<br />

<br />

.<br />

.<br />

<br />

Note that we use one element per database column.<br />

134 BES Developer’s Guide

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

Saved successfully!

Ooh no, something went wrong!