1 Reply Latest reply on Aug 6, 2002 2:13 PM by dsundstrom

    Problem with unidirectional CMR beans

      Hello,

      I encountered a scalability problem with deleting beans with unidirectional CMR. The first bean is called OIModel, and the second bean is ConceptHierarchy. Each ConceptHierarchy belongs to an OIModel, so there is a unidirectional relationship between a ConceptHierarchy and OIModel. The relationship is unidirectional because one OIModel contains a large number of ConceptHierarchy beans, and I absolutely want to avoid loading this collection (I never need it anyway).

      My problem is that whenever I delete an instance of ConceptHierarhcy, before the DELETE statement is sent to the database, JBoss still loads all the ConceptHierarhcy beans in an OIModel. Immediately before the delete, the log contains the following line:

      [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.OIModel] Executing SQL: SELECT conceptHierarchyID FROM ConceptHierarchy WHERE (modelID=?)

      Why is that happening? From an OIModel it is not possible to navigate to the ConceptHierarchy, so I assume that JBoss shouldn't ever load all ConceptHierachy beans within an OIModel. This unnecessary loading takes a lot of time, since in my case an OIModel contains some 100000 ConceptHierarchy beans. My program works correctly, but is very unscalable (actually, JBoss runs out of memory).

      The relationships are declared in the following way in the ejb-jar.xml:

      <ejb-relation >
      <ejb-relation-name>ConceptHierarchyModel</ejb-relation-name>
      <!-- unidirectional -->
      <ejb-relationship-role >
      <ejb-relationship-role-name>conceptHierarchyBean</ejb-relationship-role-name>
      <multiplicity>Many</multiplicity>
      <cascade-delete/>
      <relationship-role-source >
      <ejb-name>ConceptHierarchy</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>oIModel</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role >
      <ejb-relationship-role-name>model</ejb-relationship-role-name>
      <multiplicity>One</multiplicity>
      <relationship-role-source >
      <ejb-name>OIModel</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      The jbosscmp-jdbc.xml contains the following declarations:

      <ejb-relation>
      <ejb-relation-name>ConceptHierarchyModel</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>conceptHierarchyBean</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>model</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>modelID</field-name>
      <column-name>modelID</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>

      Is it somehow possible to turn this query off before deleting the bean?

      Similar thing happens after creating an instance of ConceptHierarchy - immediately after the INSERT statement, the log contains the following line:

      [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.OIModel] Executing SQL: SELECT conceptHierarchyID FROM ConceptHierarchy WHERE (modelID=?)

      Again, since ConceptHierarchy is unidirectional, there is no need (and not desireable in this case) to load all ConceptHierarchy beans of an OIModel.

      Thanks for the help.

      Boris Motik