I have two tables with a shared primary key where userId = id
According to JPA 2.0 Spec 184.108.40.206 Example 4, it should be possible to specify this relationship in at least two ways:
By putting @Id @OneToOne @JoinColumn annotations on the userId field, as in Case (a) of the example,
Or by creating a dummy @Id field, and using @OneToOne @JoinColumn @MapsId annotations on the userId field as in case (b) of the example.
If I specify the relationship as in case (a) AND specify the reverse mapping to UserEntity in UserDetail, then the UserDetail entites returned by queries have their user filed set to null.
If I specify the the relationship as in case (b), OR or I specify the relationship accoring to case (a), but do not specify the reverse mapping in UserEntity, then everything works as expected.
This seems somewhat similar to, and may be related to to HHH-11068, but it affects queries instead of persisting, and triggers with either annotation style.
1. Create the test tables with records from sharedPKTest.sql, and set up the app server to use it.
2. Build a WAR from the three .java files, and a persistence.xml that points to the db that has the test tables.
3. deploy the war, ( the test runs at deployment time.)
4. Experiment with the commented sections to see which combinations trigger the bug
Wildfly 10.1 on Centos 7.2 x86_64 , Java 8 and Mysql 5.7.15