I hope this helps you.

  I have multiple Categories  they are independent creatures, and can be
reused by many Traits.

Meaning a category can show up in any trait and have no knowledge of who is
using it.  The Trait knows which Category it's using.  This is a
unidirectional (trait knows category), with a N:1 relationship.  (something
like that).  anyway.  if i'm understanding your problem correctly, here
goes:


The Category Bean only has category stuff in it.  it's completely
autonomous.  it doesn't care about the rest of the world.


This is in the Trait bean

   /**
    *  get the associated category object
    *
    * @ejb.interface-method
    * @ejb.value-object
    *    aggregate="com.interfaces.CategoryValue"
    *    aggregate-name="Category"
    *    members="com.interfaces.CategoryLocal"
    *    members-name="CategoryValue"
    *    relation="external"
    * @ejb.relation
    *   name="trait-to-category"
    *   role-name="trait"
    *   target-ejb="Category"
    *   target-role-name="category"
    *   target-multiple="yes"
    * @jboss.relation
    *   related-pk-field="categoryId"
    *   fk-column="category_id_fk"
    *
    */
    public abstract com.interfaces.CategoryLocal getCategory();

You'll note this is consistent with the example given to you before, save
for the cascade-delete.

If you don't specify the target-multiple, what you end up with is

add one trait->
trait table:
  trait_id = 1,  category_id_fk = 123

add a second trait with the same category->
 trait table:
    trait_id = 1,  category_id_fk = NULL
    trait_id = 2,  category_id_fk = 123



If I understand your issue, a Model can be used by any number of Projects.
Each Project has one instance of the Model.   If this is the case, than your
Model == my Category, and your Project == my Trait.

If this still isn't what you're after.. sorry, that's how I read your
problem.

cheer!

--adam



From: Jean-philippe VIGNIEL <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [Xdoclet-user] Pb with *:1 relationship
Date: Thu, 17 Jul 2003 18:24:09 +0200

Thanks for your answer but none of them solve my problem, so that, i give
you  further explanations about my needs, i hope you will continue to help
me.

I have a class called Project and another called Model. The Model decribes a
Project so there is a single and unidirectional relation from Project to
Model and not an aggregation from Model to Project.

This relation is unidirectional because a model has to not know which
objects use it and several Projects can be described by one Model. That why
i have a n:1 and not a 1:n relation.

The ejb-jar allows to specify such a kind of relation by setting the first
<multiplicity> tag to Many and the second to One. On the other hand, xdoclet
allows to specify only the target multiplicity with the target-multiple tag
and it seems that there is no multiple tag and no other way to describe the
source multiplicity.



[EMAIL PROTECTED] wrote:

>>On Thu, 2003-07-17 at 13:27, Jean-philippe VIGNIEL wrote:
>>
>>
>>>Hi everybody
>>>
>>>I have to manage a n:1 relation ship between two entities, is it
>>>possible to generate the suitable  ejb-jar by using the xdoclet
>>>ejb.relation tag?
>>>I've  succeeded to specify a one to one relation but the only way
>>>i found to have a n to 1 relation was to set by hand the source
>>><multiplicity> tag to Many.
>>>I hope i'm not alone to need such a relation.
>>>
>>>
>>For the case where you have Bean 1 having many Bean 2's, try this
>>in
>>Bean 1 for the interface method that returns a Collection
>>
>>@ejb.relation name="Bean1-Bean2"
>>    role-name="Bean1-has-many-Bean2"
>>    target-ejb="Bean2"
>>    target-role-name="Bean2-belongs-to-Bean1"
>>    target-cascade-delete="yes"
>>
>>If you want the accessor on Bean2 then it would be something like
>>this
>>in the interface method that returns an object
>>
>>@ejb.relation name="Bean1-Bean2"
>>    role-name="Bean2-belongs-to-Bean1"
>>    cascade-delete="yes"
>>    target-ejb="Bean1"
>>    target-role-name="Bean1-has-many-Bean2"
>>    target-multiple="true"
>>
>>
>
>Hi,
>If you are defining the relationship on both entities, creating a
>bidirectional
>relation, aren't the attributes "target-cascade-delete",
>"target-role-name",
>"target-multiple" and "target-ejb" unnecessary? Reading the XDoclet
>documentation,
>http://xdoclet.sourceforge.net/tags/[EMAIL PROTECTED](0..1),
>those
>attributes are tagged as "Should *only* occur if the relation is
>unidirectional". If you define both sides of the relationship,
>XDoclet is smart
>enough to find out the values for those attributes, so you don't
>need them. At
>least my application works without them :).
>My 2ec,
>D.
>
>
>--
>This message was sent using Sake Mail, a web-based email tool from
>Endymion Corporation.  http://www.endymion.com/products/sake
>
>------------------------------------------------------------------------
>
>On Thu, 2003-07-17 at 13:27, Jean-philippe VIGNIEL wrote:
>
>
>>Hi everybody
>>
>>I have to manage a n:1 relation ship between two entities, is it
>>possible to generate the suitable  ejb-jar by using the xdoclet
>>ejb.relation tag?
>>I've  succeeded to specify a one to one relation but the only way i
>>found to have a n to 1 relation was to set by hand the source
>><multiplicity> tag to Many.
>>I hope i'm not alone to need such a relation.
>>
>>
>
>For the case where you have Bean 1 having many Bean 2's, try this in
>Bean 1 for the interface method that returns a Collection
>
>@ejb.relation name="Bean1-Bean2"
>    role-name="Bean1-has-many-Bean2"
>    target-ejb="Bean2"
>    target-role-name="Bean2-belongs-to-Bean1"
>    target-cascade-delete="yes"
>
>If you want the accessor on Bean2 then it would be something like
>this
>in the interface method that returns an object
>
>@ejb.relation name="Bean1-Bean2"
>    role-name="Bean2-belongs-to-Bean1"
>    cascade-delete="yes"
>    target-ejb="Bean1"
>    target-role-name="Bean1-has-many-Bean2"
>    target-multiple="true"
>
>
>
>




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to