Uploaded image for project: 'Hibernate ORM'
  1. HHH-11068

OneToOne shared primary key relationship breaks with field annotations

    Details

    • Type: Bug
    • Status: Awaiting Test Case
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.2.20, 5.0.9
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Environment:
      Spring boot 1.4.0 JPA starter (Hibernate 5.0.9) With H2 DB (for testing).
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      Using @OneToOne with @Id to share a primary key only seems to work if the getters (for the ID and relationship fields) are annotated. If the annotations are on the fields, then it fails. I don't know if this is accepted behaviour or not.

      Based on this example, I put together a MWE as a github repo. The master branch uses getter annotations, the `field-annotations` branch uses field annotations. Run the app with `mvn spring-boot:run` to see it fail.

      As far as I can tell, it is during the cascade merge that the link back to the parent (Book) is broken.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: