Edit: By the way this applies for one to many relations as well.
Edit2: I forgot to mention. You dont need to initialize it inside the class. It just has to be initialized before you do anything with it in jpa context.
I initialised the list in both the entity classes as you said.
Still the problem exists. I manually added data in the relationship via the SQL SErver database.
When I deploy the application the list shows correctly the selections based on the keys I entered in the database. If I just save without changing anything the error occurs.
BUT If I remove all selections from my jsf page the Save button works! and in the database what I previously entered is correctly removed.
My thinking is that at least it recognised the manytomany relationship.
Perhaps the entitymanager does not handle the lists correctly? I also tried Collection but still the same problem exists.
btw I do not have a class for the intermediate table-relationship as i read jpa handles it via the lists. Do I need a class?
Also before calling the entitymanager.merge() I print the list of participants and it shows the correct values.
My code in the AbstractFacade.java (that has all operations done by the entity manager - yes I am using the code from the CRUD application Netbeans generated for me. It was a good starting point for me as a beginner
EclipseLink version (No I haven't tried to upgrade anything so that I don't mess up anything that I managed to make it work so far :S sad i know)
I think no I don't have a null in the collection I would know when I was printing it right?
Does it matter that I don;t have an entityclass for the intermediate table? I am sure the many to many works because it removes the entries from the database when I clear the list. but to insert new, or make changes it crushes.
It is the first time I ever tried @Manytomany relationship, so far onetoone and onetomany relationships in my application work just fine.