Hello Julien,

what you would like to implement will only be available
with EJB 2.0 persistence management (relationships
are not available in EJB 1.1).
Therefore, in the current version of JOnAS, you have to
implement this kind of relationship "by hand" !
A user friendly way to implement it (using CMP, thus not
having to code your jdbc/sql join operations) is the
following :
- your reference is materialized in the database by the
  foreign key, and therefore is persistent,
- you only need to implement a "navigational" method
  to get your relationship, e.g. in your personsample bean,
  a getAccount method :
       Account getAccount() {
           if (transient_account == null)
                transient_account = <AccountHome>.findByPK(my_account_no);
           return transient_account;
       }
- you may store the result of getAccount in a transient field
  in order to avoid resolving the relationship at each access,
  i.e. you test it in the getAccount  method, or you suppress
  the getAccount method, and resolve the relationship in the
  ejbLoad and ejbActivate methods.
- as you need to refer the account home in the person bean,
  to be clean, you should use the "EJB reference" facility, which
  allows to refer the home of another bean using "logical names"
  (which will be bound at deployment time).

Hope this helps,

François


Julien RIEGERT wrote:

> Hy all!
>
> I would like to know the (easiest) way to make an Object reference with
> an EJB application, I would like to maintain two objects (2 beans...),
> for example:
>
> an object called Account (accno, customer, balance)
> and another object called Person for example which contains a reference
> to my first Object (Account), like:
> Person (perno, name, city,..., myAccount(ref Account))
>
> I know I probably have to implement both objects as Entity Beans (or
> Session), but I don't know how to declare in my EJB Java classes and the
> xml deployment description that kind of reference, I will probably
> create my database tables like this way:
>
> CREATE TABLE accountsample (
>         accno          int       PRIMARY KEY,
>         customer      VARCHAR(30),
>         balance       double
>         );
>
> CREATE TABLE personsample (
>         perno       int  PRIMARY KEY,
>                 name       VARCHAR(30),
>                 city          VARCHAR(30),
>         my_account_no   int,  -- joins to accountample.accno
>         ...);
>
> Thanks for ur responses...
>
> Best regards.
>
> --
> RIEGERT Julien
> --------------------
> *** DESS MBDS - C.E.R.A.M Sophia-Antipolis ***
> Mastère en Multimédia, Bases de Données
> et Intégration de Systèmes
> Phone: 06.12.49.16.44 - #ICQ: 75111998
> Email: [EMAIL PROTECTED]
> ----
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonas-users".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".

--
==================================================================
Francois EXERTIER         Evidian (Groupe Bull)
     1, rue de Provence,  BP 208,  38432 Echirolles cedex, FRANCE
     mailto:[EMAIL PROTECTED]
     http://www.evidian.com/jonas   http://www.objectweb.org/jonas
     Tel: +33 (0)4 76 29 71 51  -  Fax:   +33 (0)4 76 29 77 30
==================================================================


----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to