java.lang.IllegalStateException: Multiple representations of the same entity with @ManyToMany 3 entities

Fixed it by removing CascadeType.MERGE on Permission entity


The correct solution would have been to upgrade to hibernate 4.2.15 / 4.3.6 or above and add the following lines to your persistence.xml:

<property name="hibernate.event.merge.entity_copy_observer" value="allow"/>


Check your equals and hashCode method, ensure that it is consistent and correctly defined. For example I had copied and mistakenly pasted another-class when computing hashCode, this caused the object never to be equal with itself :(.