2 Replies Latest reply on Jun 26, 2002 10:48 PM by lcranford

    JDBCRemoveEntityCommand call missing

    lcranford

      Here's the code I have that's in question.



      public void removeAllLineItems()
      {
      Collection lineItems = getLineItems(); //CMR field

      for(Iterator iter = lineItems.iterator();iter.hasNext();)
      {
      LineItemLocal lineItem = (LineItemLocal)iter.next();

      iter.remove();
      }
      }



      Again, upon inspection of the database, the relationship records are deleted, but the actual Entity table (tb_LineItems) are not. Here's the item I found in the logs

      2002-06-25 20:15:53,694 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDeleteRelationsCommand.Order] Executing SQL: DELETE FROM TB_ORDER_LINEITEMS WHERE (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?) OR (line_item_id=? AND order_id=?)
      2002-06-25 20:15:53,704 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDeleteRelationsCommand.Order] Rows affected = 10

      There seems to be a missing call to the JDBCRemoveEntityCommand class for the LineItem Entity in jboss. I was told that a call iter.remove() would do this. Is this a bug?

      If you're seeing this as a double post, please ignore and forgive, as I didn't see the original post in the list

        • 1. Re: JDBCRemoveEntityCommand call missing
          dsundstrom

          Sorry, I didn't understand the post you had in the other thread. You actually want to delete all of the line items related to an order. To do that, you get the relation collection, make a copy, and then iterate over the copy and call remove on each related entity. [pre]
          public void removeAllLineItems() {
          Collection lineItems = new ArrayList(getLineItems());
          for(Iterator iter = lineItems.iterator(); iter.hasNext(); ) {
          LineItemLocal lineItem = (LineItemLocal)iter.next();
          lineItem.remove();
          }
          } [/pre]

          • 2. Re: JDBCRemoveEntityCommand call missing
            lcranford

            Yep. That worked.

            Thanks Dain!!