Francois,

Why does a unidirectional relation need the target-relation? I'm trying to 
understand what target-relation does.

On Wednesday 26 March 2003 03:37 pm, Francois Eric wrote:
> Hi,
>
> In order to do this, you must get rid of the "target" attributes in your
> @ejb.relation and put them in a @ejb.relation but on the other side.
> Also you must put the @jboss.target-relation in your other bean.  When
> you use the "target" attributes and tags, you are trying to complete a
> unidirectional cmr link.  For bidirectional cmr links, I don't believe
> you can use the foreign key mapping style.
>
> It should look something like this:
>
>     /**
>      * @ejb.interface-method view-type="local"
>      *
>      * @ejb.relation
>      *    name="Customer-Advertisement"
>      *    role-name="Customer-has-many-Advertisements"
>      *
>      * @ejb.value-object
>      *
> aggregate="ordermanager.advertisement.valueobjects.AdvertisementValue"
>      *          aggregate-name="AdvertisementValue"
>      *
> members="ordermanager.advertisement.ejb.AdvertisementLocal"
>      *          members-name="AdvertisementValue"
>      *          relation="external"
>      *          type="Collection"
>      */
>       public abstract Collection getAdvertisementLocals();
>
> and for the other bean
>
>     /**
>      * @ejb.relation name="Customer-Advertisement"
>      *      role-name="Advertisement-belongs-to-Customer"
>      *      cascade-delete="yes"
>      *
>      * @jboss.relation
>      *        fk-column="customerNumber"
>      *        related-pk-field="customerNumber"
>      *
>      * @ejb.interface-method view-type="local"
>      */
>     public abstract CustomerLocal getCustomer();
>
>     /**
>      * @ejb.interface-method view-type="local"
>      */
>     public abstract void setCustomer(CustomerLocal customer);
>
> Hope this helps,
>
> Francois
>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> [EMAIL PROTECTED]
> Sent: March 26, 2003 9:19 AM
> To: [EMAIL PROTECTED]
> Subject: [Xdoclet-user] help with relationships
>
>
> Hi all,
>
> I have two (enitity bean) classes which relate as follows:
>
>
> Customer-1----------------N->Advertisement
>
>
> So, a customer can have N advertisements, an Advertisement only belongs
> to
> 1 customer.
> (1:N relation).
>
> I have set up one side of the relation as follows:
>
>
> [code]
>     /**
>      * @ejb.interface-method view-type="local"
>      *
>      * @ejb.relation
>      *    name="Customer-Advertisement"
>      *    role-name="Customer-has-many-Advertisements"
>      *    target-cascade-delete="yes"
>      *    target-ejb="Advertisement"
>      *    target-role-name="Advertisement-belongs-to-Customer"
>      *    target-multiple="no"
>      * @jboss.relation-mapping style="foreign-key"
>      * @jboss.target-relation
>      *      fk-constraint="false"
>      *      fk-column="customerNumber"
>      *      related-pk-field="customerNumber"
>      * @ejb.value-object
>      *
> aggregate="ordermanager.advertisement.valueobjects.AdvertisementValue"
>      *          aggregate-name="AdvertisementValue"
>      *
> members="ordermanager.advertisement.ejb.AdvertisementLocal"
>      *          members-name="AdvertisementValue"
>      *          relation="external"
>      *          type="Collection"
>      */
>         public abstract Collection getAdvertisementLocals();
>
>         /**
>          * @ejb.interface-method
>          */
>         public abstract void setAdvertisementLocals(Collection
> advertisements);
>
> [/code]
>
>
> This code seems to work fine. But I guess my question is, what to put in
>
> the Advertisement class, to make the relation work both ways...?
>
> Many thanks,
>
> Harm de Laat
> Informatiefabriek
> The Netherlands
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:
> The Definitive IT and Networking Event. Be There!
> NetWorld+Interop Las Vegas 2003 -- Register today!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> _______________________________________________
> xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:
> The Definitive IT and Networking Event. Be There!
> NetWorld+Interop Las Vegas 2003 -- Register today!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> _______________________________________________
> xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user

-- 
H. L. Mencken suffers from the hallucination that he is H. L.
Mencken -- there is no cure for a disease of that magnitude.
                -- Maxwell Bodenheim



-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to