I spent a really frustrating day struggling with a weird bug in my app: some action would associate two entities via a javax.persistence.ManyToMany-mapped collection. And this association would just be ignored by Hibernate, the link table/join table remained empty. Finally, I found the solution in a post by Adrian Smith (and an update specifically for JPA in a comment by Sat Freak). You saved my day! I’m linking it here so that people may perhaps find it more easily.
The solution: do a flush(), then a merge(), then a commit(). Looks quite strange to me, and I can’t wrap my head around why that works and all my other approaches didn’t. But work it does.