9 Replies Latest reply on Apr 10, 2006 5:03 AM by Alexander Hartner

    Many2Many using ArrayList causing strange muliplication effe

    Alexander Hartner Expert

      I have a bidirectional many 2 many relationship between a contact and an address entity. A contact also has a bidirectional one 2 many relationship with contact details.
      The problem manifest itself when I do the following :

      create a contact with 10 contact details
      find the contact
      add 10 new addresses to the contact
      merge the contact
      find the contact again

      After the contact has been merged back the collection of the contact has 100 addresses in it. I have done the same sequence but only added 3 or 5 contact details in the beginning. The results where 30 or 50 addresses being returned.

      The database, funny enough, only has 10 addresses, and is correct. It seems as if the persistence context is getting corrupted ?

      I have changed to use a Set which resolved this problem. I am hoping that anybody else has similar experiences and has another solution.