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 />

To model the relationship between these two tables, a cross-table must be created. For<br />

example, to create a cross-table that shows employee names and the names of the<br />

projects on which they are working, the element would look like the<br />

following:<br />

<br />

<br />

EMPLOYEE<br />

<br />

EMP_NO<br />

LAST_NAME<br />

PROJ_ID<br />

<br />

<br />

<br />

EMPLOYEE_PROJECTS<br />

<br />

EMP_NAME<br />

PROJ_ID<br />

<br />

<br />

PROJ_ID<br />

PROJ_NAME<br />

<br />

<br />

<br />

PROJECT<br />

<br />

PROJ_ID<br />

PROJ_NAME<br />

EMP_NO<br />

<br />

<br />

<br />

Since these are “secondary tables” and therefore have no primary keys, the PROJ_ID<br />

column appears in both column lists. This could also be the common column EMP_NO,<br />

depending upon how you wish to model the data.<br />

Using cascade delete and database cascade delete<br />

Use when you want to remove entity bean objects. When cascade<br />

delete is specified for an object, the container automatically deletes all of that object's<br />

dependent objects. For example you may have a Customer bean which has a one-tomany,<br />

uni-directional relationship to an Address bean. Because an address instance<br />

must be associated to a customer, the container automatically deletes all addresses<br />

related to the customer when you delete the customer.<br />

To specify cascade delete, use the element in the ejb-jar.xml file as<br />

follows:<br />

<br />

Customer-Account<br />

<br />

Account-Has-Customer<br />

<br />

one<br />

<br />

<br />

<br />

Chapter 15: Entity Beans and Table Mapping for CMP 2.0 139

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

Saved successfully!

Ooh no, something went wrong!