Is CMR methods necessary in CMP Entity Beans?

Advertisement

Is CMR methods necessary in CMP Entity Beans?
I refer to the J2EE 1.3.1 SDK CMP Customer application sample.
I looked thru the CMP sample source code from the J2EE 1.3.1 SDK under /j2sdkee1.3.1/doc/sample and found that for every relationship the CustomerBean has with another Bean, there has to be some CMR methods.
In this case, Customer has a:
public abstract void addAddress(LocalAddress address)
public abstract void addSubscription(LocalAddress)
For the other That I understand. It's like specifying the foreign key for the record, so to speak.
So for every foreign key field in other Beans (tables), does CustomerBean need a CMR method (get/set)? So if CustomerBean has 20 other tables using the CustomerID as a foreign key, does that imply that CustomerBean will have at least 20 CMR methods so that other Beans can add themselves and connect to CustomerBean?
Another thing I noticed is that for Beans with foreign key(s) (sorry for including database terms, perhaps just called reference now in J2EE), they all link up to the other Beans (tables) in ejbPostCreate by adding themselves to the Bean Collection.
Repaly
IMHO you don't have to map every relationship
(at DB level) when you declare CMR fields
at EJB level.
You have to answer at this question:
"When I load/find an Entity Bean, I need, at the same time,
to load Bean related to the Entity Bean ?".
If the answer is YES then you'll declare a CMR
field to express the relatiosnhip.
Moreno
Read More: The other 2 answers