5 Replies Latest reply on May 22, 2002 4:03 AM by Tim Fox

    CMR fields and referential integrity

    Tim Fox Master

      For the sake of argument, I have two entity beans:

      Order and OrderItem:

      There is a one-many relationship:

      "An order is composed of many order items".

      The order-item table has a foreign key (orderid) mapping back to the order table.

      When I create a new order order item, I set the CMP fields in the ejbCreate() method, and I set the order CMR field in the ejbPostCreate() method, as per the ejb spec I believe.

      Jboss then first attempts to insert a new order item with a NULL orderid, and then do an UPDATE to set the orderid.

      Of course the INSERT fails, since the foreign key column is NOT NULL as per standard sensible database design.

      I am stumped here - does Jboss expect me to drop referential integrity on my database so I can persist ejbs with CMR relations??