5 Replies Latest reply on Jul 20, 2002 11:57 PM by Dain Sundstrom

    One to Many Remove Problem

    Lance Cranford Newbie

      I have a simple Order-LineItem Uni-Directional One-to-Many Relationship defined between two EntityBeans (with cascade delete defined on the many side, LineItem). I'm using relation-table-mapping, so I have three tables (tb_Orders, tb_LineItems and tb_Orders_LineItems). Everything is working as expected, but now I want to implement a removeAllLineItems() on my OrderBean. I thought that I could simple invoke the getLineItems().clear() method to perform this use case (Deleting from both the tb_Orders_LineItems and tb_LineItems table). However, only the records in the relation table is being deleted, thus leaving orphaned records in tb_LineItems. How do I correctly implement this on JBoss-3.0.0? Note: I was going to just iteratate over the collection calling the EJBLocalObject.remove(), but according to the EJB 2.0 spec (ref: 10.3.6.1), the container will/should throw an IllegalStateException. Do I call Iterator.remove(), instead?