New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OneToOne-association produces error on 2.2.0.RELEASE when using PostgreSQL #20181
Comments
Thanks for the report. I suspect that this may be a Hibernate problem. Spring Boot 2.1 uses Hibernate 5.3 whereas 2.2 uses Hibernate 5.4. What happens if you use Spring Boot 2.1 but override |
Thanks, I could drill it down to an issue that sneaked into Hibernate 5.4.* and placed a new issue at their side. |
Great. Thanks for letting us know. For anyone who wants to follow along, it looks like HHH-13866 is the Hibernate issue that @pfuerholz created. |
This error occurs when using OneToOne associations using 'shared primary key'. In this case the primary key in the owned class (PaymentBatchJobDO) is set to owning class (PaymentDO). In this case Hibernate's EntityManager.merge() method gets called instead of persist() (merge() is typically used for updates, persist() for saving new entities). Before Hibernate 5.4.* merge() were able to recognize that the entity has not yet been persisted. Solutions / workarounds:
|
@pfuerholz I'm not sure that I understand why you've re-opened the issue. Are you proposing that an enhancement be made so that determining whether to call |
@wilkinsona Thanks for commenting. Furthermore Spring tells about implementing the Persistence-instance for deciding if an entity is already saved or not. After all I do not know if there arose an error at all or if I had just luck that it worked in the old code. |
Thanks for the additional information. We can't do anything about that question in Spring Boot itself as whether merge or persist is used is out of Spring Boot's control. It may be something that Spring Data JPA can influence. If you'd like raise the issue there, they use JIRA for issue tracking but I think it's probably better to wait until the Hibernate issue has been resolved before considering any changes on the Spring Data JPA side of things. |
We have Spring Boot application using a OneToOne annotation and PostgreSQL.
Owning class:
Owned class:
Until Spring Boot 2.1.12 is worked perfecty but with 2.2.0+ I get following error:
If I use a H2 database the error does not occur.
Configuration:
There are different ways to implement a OneToOne relationship. If I change to the (more typical) was:
Owned class:
I get following error:
--> paymentbat0_.payment_payment_id does not exist!
The text was updated successfully, but these errors were encountered: