We're updating the issue view to help you get more done. 

Entity with multiple reference to a composite-id foreign key throws EntityExistsException

Description

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

Environment

Hibernate 5.1, Wildfly 10.0, Java 8

Status

Assignee

Unassigned

Reporter

Giovanni Lovato

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.1.0

Priority

Major