[hibernate-issues] [JIRA] (HHH-11496) Wrong insert order for OneToOne associations

Vlad Mihalcea (JIRA) jira at hibernate.atlassian.net
Thu Mar 26 06:16:17 EDT 2020


Vlad Mihalcea ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Af5e8c0d3-3aae-4bb4-a4e1-25463d60d232 ) *commented* on HHH-11496 ( https://hibernate.atlassian.net/browse/HHH-11496?atlOrigin=eyJpIjoiMTFmMzhiOWE5M2RlNGIzNzlmOGY2NTZlMGNkYTY2MmIiLCJwIjoiaiJ9 )

Re: Wrong insert order for OneToOne associations ( https://hibernate.atlassian.net/browse/HHH-11496?atlOrigin=eyJpIjoiMTFmMzhiOWE5M2RlNGIzNzlmOGY2NTZlMGNkYTY2MmIiLCJwIjoiaiJ9 )

The best way to create a test case for Hibernate is to fork the repository and create the test based on some existing one, as explained in this article ( https://in.relation.to/2018/06/04/best-way-write-hibernate-orm-issue-test-case/ ).

You shouldn’t use frameworks like Spring or Lombok, as they could interfere with the replicating test case.

Once you do that, you should create a new Jira issue, as this one is closed and doesn’t use the same mappings as your own.

Also, your mappings are wrong. The entity you called Child is actually the parent entity. The entity you called Parent is the one that contains the FK, so it should be the child instead.

And, cascading from the child side to the parent is also a mistake. How can a child exist prior to its parent?

And, you are better off using @MapsId instead of @PrimaryKeyJoinColumn. Check out this article ( https://vladmihalcea.com/the-best-way-to-map-a-onetoone-relationship-with-jpa-and-hibernate/ ) for more details.

Now, I’m no longer working on the Hibernate project, so once you add the test case as a Pull Request, someone from the team should review it.

( https://hibernate.atlassian.net/browse/HHH-11496#add-comment?atlOrigin=eyJpIjoiMTFmMzhiOWE5M2RlNGIzNzlmOGY2NTZlMGNkYTY2MmIiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-11496#add-comment?atlOrigin=eyJpIjoiMTFmMzhiOWE5M2RlNGIzNzlmOGY2NTZlMGNkYTY2MmIiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100122- sha1:93a3ad8 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200326/08a54e29/attachment.html 


More information about the hibernate-issues mailing list