1 Reply Latest reply on Jul 10, 2002 4:38 PM by Dain Sundstrom

    Wrong behaviour (IMHO) of CMP for updating Relationships

    Hans Newbie

      Hi,

      Env: JBoss 3.0 + MySQL and Hsqldb

      There are two entity-beans A and B with a bidirectional 1-1 Relationship. The relationship-mapping is via foreign keys. It works usually fine with CMP-setting of the foreign keys but not in this scenario:

      class A {
      abstract setB(LocalB b) {}
      setToExistingB(Integer primaryKeyB) {
      setB(homeLocalB.findByPrimaryKey(primaryKeyB));
      }
      }

      class Client {
      a = homeRemoteA.create(...);
      a.setBViaDataObject(new BDO(...));
      b = homeRemoteB.create(...);
      a.setToExistingB((Integer)b.getPrimaryKey);
      }

      Afterwards the Table for B is fine but not for A, which
      should have a0(fk_id_B = 1).

      Table B: b0(fk_id_A = empty),b1(fk_id_A = 1)
      Table A: a0(fk_id_B = 0)