2 Replies Latest reply on Jul 1, 2002 2:00 AM by adiraju

    Problem with 1:1 CMP example from MasteringEJB2

    adiraju

      Hi,

      I'm trying to deply Order-Shipment 1:1 CMP example from EdRomans book.
      as in the book in my ejb-jar.xml I have,
      ......OrderBean
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>OrderBean</abstract-schema-name>
      <cmp-field><field-name>orderID</field-name></cmp-field>
      <cmp-field><field-name>name</field-name></cmp-field>
      <primkey-field>orderID</primkey-field>

      .......ShipmentBean

      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>ShipmentBean</abstract-schema-name>
      <cmp-field><field-name>shipmentID</field-name></cmp-field>
      <cmp-field><field-name>city</field-name></cmp-field>
      <cmp-field><field-name>zipcode</field-name></cmp-field>
      <primkey-field>shipmentID</primkey-field>

      ......Relationship filed
      <cmr-field>
      <cmr-field-name>shipment</cmr-field-name>
      </cmr-field>

      ......

      I have declared two methods in Order entity bean class as
      public abstract getShipment();
      public abstract void setShipment(Shipment s);

      The tables created by JBoss are as follows
      Table: Order
      ------------
      Field 1: ORDERID(PK)
      Field 2: NAME
      Field 3: SHIPMENT

      Table: Shipment
      Field 1: SHIPMENT(PK)
      Field 2: CITY
      Field 3: ZIPCODE
      Field 4: ORDERS_SHIPMENT

      There is no FK constraint created.

      Obviously the foriegn key relationship os missing. Where should i specify this. Please help!



        • 1. Re: Problem with 1:1 CMP example from MasteringEJB2
          lcranford

          If you're using JBoss-3.0.0, then update the standardjbosscmp-jdbc.xml file in your conf directory.

          change

          <fk-constraint>false</fk-constraint>

          to...

          <fk-constraint>true</fk-constraint>

          • 2. Re: Problem with 1:1 CMP example from MasteringEJB2
            adiraju

            Thanks.
            Now I have the FK's created.

            Still one problem remaining though.
            I have the 1:1 relationship direction Order --> Shipment.
            So I have the field in the Order side of the relationship.I have 'NO' <cmr-field> on the shipment side.

            Order Table created is fine. But my Shipment table created is as below

            Table: Shipment
            ---------------
            Field 1: SHIPMENT(PK)
            Field 2: CITY
            Field 3: ZIPCODE
            Field 4: ORDERS_SHIPMENT (FK to Order.OrderID)

            Why is this? How do i get rid of this extra field. I do not have this in my <cmp-field>'s.