0 Replies Latest reply on Dec 23, 2008 4:12 AM by ravi krishna muthireddy

    many-to-many problem when passing collection

    ravi krishna muthireddy Newbie

      Hi,
      I am ramu, i am getting a problem when persisting data in many to many mapping.

      vendor---->industry is many to many mapping

      I am taking two industries objects and passing them to one vendor as a collection

      Vendor v = manager.find(Vendor.class, 3);
      Industry i = manager.find(Industry.class, 2);
      Industry i1 = manager.find(Industry.class, 3);
      List l1 = new ArrayList();
      l1.add(i);
      l1.add(i1);
      v.setIndustries(l1);
      v.getIndustries().add(i);
      i.getVendors().add(v);
      manager.persist(v);

      it is adding only one row in join table.but it should add two records for vendor 3

      any help please
      Thank you
      KRamu