I was trying to do a Many-to-many setup with a link entity ([as described in the manual|http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#associations-many-to-many-bidirectional-with-link-entity]).
Using the entities from the manual, when I call {{Session.merge}} after assigning an {{Address}} to a {{Person}}, Hibernate attempts to insert a {{(null, null)}} tuple into the link table. The problem only affects {{merge}} – {{persist}} seems to work fine.
I've stepped through it with a debugger and it seems, that {{SessionImpl.instantiate}} (called during the cascading merge) does not copy over the two {{@Id}} fields.
I've reproduced it with 5.2.2, 5.2.1 and 5.0.9, with both PostgreSQL and H2. Both databases won't insert the null values into the primary key, of course.
A test case is attached. |
|