2 Replies Latest reply on Dec 16, 2001 3:00 PM by griveo2883

    How to model a one-to-many relationship in CMP 1.1 (JBoss 2.

    griveo2883

      Hi

      I am trying to model a one-to-many database relationship in CMP 1.1. I cannot use CMP 2.0 (jboss 3), because my ISP supports jboss 2.4.1.

      As far as I have studied EJBs and JBoss, in that scenario, I should have to use "dependent objects", which would hold a list of the PKs of the entity beans related to the one that would contain the "dependent object".

      Is this true? Otherwise, could someone please tell me which is the right approach, and where to find more info about it?

      By the way, in the example shown in the section "Dependent Value Objects [since JBoss 2.4]", in the "Documentation" area of www.jboss.org, it seems that the relationship between the entity bean and the dependent object is one-to-one, and that JAWS simply adds fields to the table associated to the entity bean. I think this would not be possible in a one-to-many relationship, because JAWS would have to add an indefinite number of fields to the associated db table.

      Could someone please tell me what should I do?

      THANKS IN ADVANCE

      Luis

        • 1. Re: How to model a one-to-many relationship in CMP 1.1 (JBos
          haytona

          As far as I'm aware dependant objects are for adding ONE address object to an order object for example. For when a standard datatype (e.g. String) is not enough.

          I made a pretty rough tutorial for CMP 1.1 relationships at
          www.geocities.com/haytona/reltut

          give it a go and leave me some feed back if you7 want it improved in any way.

          To summarise how to do it:
          Bean A has zero or more Bean B relations.
          We would store the primary key of Bean A in Bean B. Then to get all relations of Bean A we would call a finder on Bean B to the effect of FindByBeanAPrimaryKey.

          haytona

          • 2. Re: How to model a one-to-many relationship in CMP 1.1 (JBos
            griveo2883

            Hi, haytona !!!

            Thank you very much for your quick, smart answer !!!

            I will study your tutorial, and give feedback to you, but just the overview given in your message sounds GREAT !!!

            I will try it

            Again, THANK YOU VERY MUCH

            Cheers

            Luis