OneToOne shared primary key relationship breaks with field annotations

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.

Environment

Spring boot 1.4.0 JPA starter (Hibernate 5.0.9) With H2 DB (for testing).

Activity

Show:
Gail Badner
September 18, 2017, 10:10 PM

Please provide a simple test case that does not use spring that reproduces your issue. Test templates are at: https://github.com/hibernate/hibernate-test-case-templates

Julien Gouesse
September 19, 2017, 10:51 AM

I got rid of the GenericJDBCException by increasing the TTL of the connection in use provided by the pool. I use Hibernate 5.0.10 Final, it works like a charm now. The main difference between my source code and the one provided in this bug report is the use of sequences in mine instead of auto incremental values.

Gail Badner
September 19, 2017, 6:02 PM

, are you saying this is no longer an issue?

Julien Gouesse
September 19, 2017, 7:17 PM

Yes, I can try to reproduce this bug with the SQL tables mentioned by the original poster but with PostgreSQL or Oracle instead of MySQL. I expect it to work correctly.

Gail Badner
September 20, 2017, 8:33 PM

, I'm not sure if I understand. Can this issue be closed?

Assignee

Unassigned

Reporter

P

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure