2 Replies Latest reply on Apr 15, 2002 2:07 PM by Corey O'Donovan

    Problem with CMR

    George Chitishvili Newbie

      Hi all,

      I have the latest CVS Version of JBoss 3.0.0betha2 and try to programm two CMP2.0 Entity Beans with One-Many relation.
      As far as I want to read data, it works good (only if I
      set reentract to true in ejb-jar.xml), but if I want to create a Bean, which references another bean there is a following problem:

      The foreign key field in DB Table can NOT be NULL and as JBoss tries to insert a new row in this Table, it get error-message from DBMS.

      The Relation-fields can only be set in ejbPostCreate().
      (If I do it in ejbCreate() I got Exception:
      java.lang.IllegalStateException: A CMR field cannot be set in ejbCreate; this should be done in the ejbPostCreate method instead [EJB 2.0 Spec. 10.5.2]

      and if I do in ejbPostCreate JBoss is not able to create a row in DB Table, cause FK value is NULL at the moment.

      Is there only way to avoid this problem just removing the NOT NULL constraint in DB-Scheme. Not the best solution.