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 everybodyI 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"
