3 Replies Latest reply on Jun 25, 2002 1:27 PM by Dain Sundstrom

    Strange queries in Many to One relationship

    Dave Brown Newbie

      Hi,

      I have a problem with the queries being generated against my database (PostgreSQL) using JBoss-3.0.0. The application takes advantage of the new CMP code.

      From the logs it can be seen when I create a new customer object the system gets the appropriate status object and then for some reason selects all the Customers with that status.

      Anyone got any idea why this is happening and how I can avoid it?

      Regards,
      Dave.

      CustomerEJB (Many) -> CustomerStatusEJB (One)

      2002-06-23 10:06:41,115 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.CustomerStatusEJB] Executing SQL: SELECT status FROM customerstatusejb WHERE (id=?)
      2002-06-23 10:06:41,119 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.CustomerStatusEJB] Executing SQL: SELECT id FROM customerejb WHERE (status=?)

      <!-- Customer - CustomerStatus -->
      <ejb-relation>
      <ejb-relation-name>CustomerEJB-CustomerStatusEJB</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>CustomerEJB</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>CustomerEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>status</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>CustomerStatusEJB</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>CustomerStatusEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>