0 Replies Latest reply on Oct 20, 2003 3:35 AM by Billy Li

    composite primary key relationship

    Billy Li Newbie

      Hi, all,
      Two beans:
      SalesOrders (orderId)
      OrderLineItems(orderId, lineId)
      I am trying to setup the relationship between two CMP2 managed relationships. I can successfully deploy the beans but JBOSS3.2.2RC3 keeps throwing javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=com.heidenhain.scala.OrderLinePK@10948cf.

      Anybody can help please?
      Thanks in advance.
      <ejb-jar >

      Heidenhain Scala EJB
      <display-name>Heidenhain Scala CMP2.0</display-name>

      <enterprise-beans>


      Sales Order Bean
      <display-name>Sales Order Bean</display-name>
      <ejb-name>SalesOrderEJB</ejb-name>
      <local-home>interfaces.SalesOrderHome</local-home>
      interfaces.SalesOrder
      <ejb-class>ejb.SalesOrderBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <transaction-type>Container</transaction-type>
      <abstract-schema-name>salesorders</abstract-schema-name>
      <cmp-field><field-name>orderId</field-name></cmp-field>
      <cmp-field><field-name>customerId</field-name></cmp-field>
      <cmp-field><field-name>orderTotalValue</field-name></cmp-field>
      <cmp-field><field-name>taxRate</field-name></cmp-field>
      <cmp-field><field-name>poStatus</field-name></cmp-field>
      <cmp-field><field-name>salesMan</field-name></cmp-field>
      <cmp-field><field-name>invoiceNo</field-name></cmp-field>
      <primkey-field>orderId</primkey-field>

      <query-method>
      <method-name>findByCustomerId</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(s) FROM salesorders s WHERE s.customerId = ?1</ejb-ql>



      Sales Order LineItem Bean
      <display-name>Sales Order LineItem Bean</display-name>
      <ejb-name>SalesOrderLineItemEJB</ejb-name>
      <local-home>interfaces.SalesOrderLineItemHome</local-home>
      interfaces.SalesOrderLineItem
      <ejb-class>ejb.SalesOrderLineItemBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.heidenhain.scala.OrderLinePK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <transaction-type>Container</transaction-type>
      <abstract-schema-name>salesOrderLineItem</abstract-schema-name>
      <cmp-field><field-name>orderId</field-name></cmp-field>
      <cmp-field><field-name>lineId</field-name></cmp-field>
      <cmp-field><field-name>stockCode</field-name></cmp-field>
      <cmp-field><field-name>description1</field-name></cmp-field>
      <cmp-field><field-name>description2</field-name></cmp-field>
      <cmp-field><field-name>unitPrice</field-name></cmp-field>
      <cmp-field><field-name>quantityOrdered</field-name></cmp-field>
      <cmp-field><field-name>quantityShipped</field-name></cmp-field>



      </enterprise-beans>

      <!-- Relationships -->

      <ejb-relation>
      <ejb-relation-name>customer-salesOrders</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>customer-has-salesorders</ejb-relationship-role-name>

      One

      <relationship-role-source>
      <ejb-name>CustomerEJB</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>salesOrders</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>salesorder-customer</ejb-relationship-role-name>

      Many

      <relationship-role-source>
      <ejb-name>SalesOrderEJB</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>customer</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>SalesOrder-OrderLineItem</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>salesorder-orderlineitems</ejb-relationship-role-name>

      One

      <relationship-role-source>
      <ejb-name>SalesOrderEJB</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>lineItems</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>lineitems-salesorder</ejb-relationship-role-name>

      Many

      <relationship-role-source>
      <ejb-name>SalesOrderLineItemEJB</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>salesOrder</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      <!-- Assembly Descriptor -->
      <assembly-descriptor >

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- transactions -->

      <!-- finder transactions -->
      </assembly-descriptor>

      </ejb-jar>

      <jbosscmp-jdbc>

      java:/scalaDB
      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <read-only>true</read-only>
      <pk-constraint>true</pk-constraint>



      <enterprise-beans>


      <ejb-name>CustomerEJB</ejb-name>
      <table-name>SL017800</table-name>
      <cmp-field>
      <field-name>customerId</field-name>
      <column-name>SL01001</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>customerName</field-name>
      <column-name>SL01002</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>taxCode</field-name>
      <column-name>SL01022</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>address</field-name>
      <column-name>SL01003</column-name>
      <not-null/>
      </cmp-field>



      <ejb-name>SalesOrderEJB</ejb-name>
      <table-name>OR017800</table-name>
      <cmp-field>
      <field-name>orderId</field-name>
      <column-name>OR01001</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>customerId</field-name>
      <column-name>OR01003</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>invoiceNo</field-name>
      <column-name>OR01021</column-name>
      <not-null/>
      </cmp-field>

      <cmp-field>
      <field-name>orderTotalValue</field-name>
      <column-name>OR01024</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>poStatus</field-name>
      <column-name>OR01006</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>taxRate</field-name>
      <column-name>OR01036</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>salesMan</field-name>
      <column-name>OR01017</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>invoiceNo</field-name>
      <column-name>OR01018</column-name>
      <not-null/>
      </cmp-field>


      <ejb-name>SalesOrderLineItemEJB</ejb-name>
      <table-name>OR037800</table-name>
      <cmp-field>
      <field-name>orderId</field-name>
      <column-name>OR03001</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lineId</field-name>
      <column-name>OR03002</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>stockCode</field-name>
      <column-name>OR03005</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>description1</field-name>
      <column-name>OR03006</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>description2</field-name>
      <column-name>OR03007</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>unitPrice</field-name>
      <column-name>OR03008</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>quantityOrdered</field-name>
      <column-name>OR03011</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>quantityShipped</field-name>
      <column-name>OR03012</column-name>
      </cmp-field>



      </enterprise-beans>


      <ejb-relation>
      <ejb-relation-name>customer-salesOrders</ejb-relation-name>
      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>customer-has-salesorders</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>customerId</field-name>
      <column-name>OR01003</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>salesorder-customer</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>SalesOrder-OrderLineItem</ejb-relation-name>
      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>salesorder-orderlineitems</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>orderId</field-name>
      <column-name>OR03001</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>lineitems-salesorder</ejb-relationship-role-name>
      <key-fields>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>

      <dependent-value-classes>
      <dependent-value-class>
      Order Line multi-part primary key
      com.heidenhain.scala.OrderLinePK

      <property-name>orderId</property-name>
      <column-name>OR03001</column-name>


      <property-name>lineId</property-name>
      <column-name>OR03002</column-name>

      </dependent-value-class>
      </dependent-value-classes>

      </jbosscmp-jdbc>


      package com.heidenhain.scala;
      public class OrderLinePK implements java.io.Serializable{
      public String orderId;
      public String lineId;
      public OrderLinePK () {
      }
      public String getOrderId() {
      return this.orderId;
      }
      public void setOrderId(String oid) {
      this.orderId = oid;
      }
      public String getLineId() {
      return this.lineId;
      }
      public void setLineId(String lid) {
      this.lineId = lid;
      }
      }