Creating issue for discussion here at https://discourse.hibernate.org/t/hibernate-onetoone-with-mapsid-does-not-map-the-same-id-with-the-parent-entity/2093/9
A child entity is mapped using @OneToOne with @MapsId to its parent entity.
The assumption is that child will refer to its correct parent in any case. However, following code will break this assumption.
This way it will continue to use new parent until the end of transaction.
@OneToOne with @MapsId should always resolves to correct association value.
Sample test cases which show the issue.
Hibernate Version: 5.2.17
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)