Hi again!

The associative table has its pro and cons. As severel of you pointed out,
the use of a associative table makes the tables a lot cleaner. But as our
complex world seems to be full of multiplicity, I personally would think
twice, when the domain model is large. I did a little test to measure the
difference.

I created 100 orders with 10 orderlines each, i.e. 1000 records.
With an associative table this took: approximately 47 seconds.
Without it took: 27 seconds.

In the second test I had to make a workaround (I normalized the beans), so
the test could be misleading. But it takes me back to my original problem.
When Orion autocreates table it automatically create a associative table,
which I don't want. Naturally I want the primary key of the one side to be
placed as a foreign key in the many side. My ejb-jar.xml looks like this:

<ejb-jar>

     <enterprise-beans>

          <entity>
               <description>Order holds a number of Orderlines.</description>
               <display-name>JOrder</display-name>
               <ejb-name>JOrderOne</ejb-name>
               <home>OrderHome</home>
               <remote>Order</remote>
               <ejb-class>OrderBean</ejb-class>
               <persistence-type>Container</persistence-type>
               <prim-key-class>java.lang.String</prim-key-class>
               <reentrant>True</reentrant>
               <cmp-version>2.x</cmp-version>
               <cmp-field>
                    <field-name>orderId</field-name>
               </cmp-field>
               <cmp-field>
                    <field-name>orderLines</field-name>
               </cmp-field>
               <primkey-field>orderId</primkey-field>
          </entity>

          <entity>
               <description>Holds the ordered items of a customer</description>
               <display-name>JOrderLine</display-name>
               <ejb-name>JOrderLineOne</ejb-name>
               <home>OrderLineHome</home>
               <remote>OrderLine</remote>
               <ejb-class>OrderLineBean</ejb-class>
               <persistence-type>Container</persistence-type>
               <prim-key-class>java.lang.String</prim-key-class>
               <reentrant>True</reentrant>
               <cmp-version>2.x</cmp-version>
               <cmp-field>
                    <field-name>orderLineId</field-name>
               </cmp-field>
               <primkey-field>orderLineId</primkey-field>
          </entity>
     </enterprise-beans>
     <relationships>
          <ejb-relation>
               <description>Order-OrderLines</description>
               <ejb-relation-name>Order-Orderlines</ejb-relation-name>
               <ejb-relationship-role>
                    <description>Order has Orderlines</description>
                    
<ejb-relationship-role-name>Order-has-Orderlines</ejb-relationship-role-name>
                    <multiplicity>one</multiplicity>
                    <role-source>
                         <ejb-name>JOrderOne</ejb-name>
                    </role-source>
                    <cmr-field>
                         <cmr-field-name>orderLines</cmr-field-name>
                         <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
               </ejb-relationship-role>
               <ejb-relationship-role>
                    
<ejb-relationship-role-name>OrderLines-belongsto-Order</ejb-relationship-role-name>
                    <multiplicity>many</multiplicity>
                    <role-source>
                         <ejb-name>JOrderLineOne</ejb-name>
                    </role-source>
               </ejb-relationship-role>
          </ejb-relation>
     </relationships>
     <assembly-descriptor>
     </assembly-descriptor>
</ejb-jar>

So, what is the solution to this problem? Is there any faults in the xml file above? 
Or is there another solution to my problem?

I also read that the bug #140, maintaining a bidirectional 1-n relation, is fixed. 
This is of course not a bidirectional relationship, but if Orion
could
handle this wouldn't it be naturally to suppose that it could handle unidirectional 
relationships.

Regards, Theis.



Reply via email to