1 Reply Latest reply on Aug 27, 2002 5:00 AM by Jochen Cordes

    Remove a collection in CMR

    Wallace Zou Newbie

      JBoss 3.0.0 + Mysql + JDK1.4

      I have completed a 1:n unidirection CMR system (entity bean A and B), the relation is mapped by foreign key. Now what I do is to delete a set of entity B from A's collection.

      What I have are B's primary keys. I do it this way:

      1, I built a java.util.Collection r contains the all local interface of B I am going to delete. (I use findByPrimaryKey to get those lcoal interface)

      2, I'd like to make sure those Bs' local interfaces are belong to a certain A, so I get a another java.util.Collection w by call A's getBLocals(). Then I call w.removeAll(r) to remove r from w.

      As the result, I found the B wasn't removed actually, but the foreign key is assigned to null, the records are exist. Is there any wrong in my work or the best way I should do? Appreciated your replies!

      Best Regards,