On Mon, 24 Jul 2000 00:12:09 -0700, Jerson Chua <[EMAIL PROTECTED]>
wrote:
>I'm just new to EJB so please bear with my basic EJB question.
>How to you model one to many relationship in EJB? I've checked the one in
>Richard-Monson
>Haefel book (356-357, CabinPK stored in Vector cabins) and J2EE blueprint
>(ShoppingCartEJB, it stores itemNo). Both used the primary key to reference dependent
>objects. Isn't it true that entity bean must contain a list of direct references to
>those dependent objects rather than using primary keys to reference dependent objects?
In general, using the primary key to store the reference is a much safer
way to go, since a handle may include the hostname of the server (and
what happens if you change server... the entire store is lost!?).
> I
>also noticed that it converts the key to object on the fly whenever the
>getManyObjects()
>is called. Is this a normal practice?
IMHO the best way to solve this generally is to have the many side point
to the one side, and then use finders. I.e., if X is on the many side
and Y is on the one side you could have a finder method "findByY(someY)"
in the X home, and in the Y remote interface a method "getAllX" which
simply calls the finder method on X and return the result.
/Rickard
--
Rickard �berg
Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.com
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".