If an entity contains multiple reference to a composite-id foreign key, any attempt to persist/merge throws an EntityExistsException.
Say we have Company and Customer where Customer has a id composed of a Long and a Company; it has also a Customer related. If we try to persist/merge an instance a Customer with another instance as its related, both having the same Company instance, the exception is thrown.
Gist example: https://gist.github.com/heruan/9cbe7ae13f94d4fc2d2c
Hibernate 5.1, Wildfly 10.0, Java 8