Skip to Content
Enterprise JavaBeans, Third Edition
book

Enterprise JavaBeans, Third Edition

by Richard Monson-Haefel
September 2001
Intermediate to advanced content levelIntermediate to advanced
592 pages
18h 22m
English
O'Reilly Media, Inc.
Content preview from Enterprise JavaBeans, Third Edition

Relationship Fields

Entity beans can form relationships with other entity beans. In Figure 6-1, at the beginning of this chapter, the Customer EJB is shown to have a one-to-one relationship with the Address EJB. The Address EJB is a fine-grained business object that should always be accessed in the context of another entity bean, which means it should have only local interfaces and not remote interfaces. An entity bean can have relationships with many different entity beans at the same time. For example, we could easy add relationship fields for Phone, CreditCard, and other entity beans to the Customer EJB. At this point, however, we’re choosing to keep the Customer EJB simple.

Following Figure 6-1 (earlier in the chapter) as a guide, we define the Address EJB as follows:

            package com.titan.address;

import javax.ejb.EntityContext;

public abstract class AddressBean implements javax.ejb.EntityBean { public Integer ejbCreateAddress(String street, String city, String state, String zip) { setStreet(street); setCity(city); setState(state); setZip(zip); return null; } public void ejbPostCreateAddress(String street, String city, String state, String zip) { } // persistence fields public abstract Integer getId(); public abstract void setId(Integer id); public abstract String getStreet(); public abstract void setStreet(String street); public abstract String getCity(); public abstract void setCity(String city); public abstract String getState(); public abstract void setState(String state); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Enterprise JavaBeans, Fourth Edition

Enterprise JavaBeans, Fourth Edition

Sacha Labourey, Bill Burke, Richard Monson-Haefel
EJB™ 2.1 Kick Start

EJB™ 2.1 Kick Start

Peter Thaggard

Publisher Resources

ISBN: 0596002262Supplemental ContentCatalog PageErrata