OneToOne SQL missing parameter

Description

Hibernate fails to query OneToOne association from the non-owning side when there is a reference inside the where clause. The behaviour was observed on both Hibernate 3.5.6 and 3.6.0 and tested in H2 and PostgreSQL environments.

Given two entities:

If the query is issued from the owning side of the association, everything works as expected.

However, if the query is issued from the non-owning side, the exception is thrown.

The stacktrace produced with H2 database used:

Environment

Hibernate 3.5.6 / 3.6.0
H2 1.2.143 (in-memory) / PostgreSQL 9.0-801.jdbc4

Activity

Show:
Brett Meyer
April 8, 2014, 2:03 PM

, thanks much for the reponse!

Steve Ebersole
October 27, 2015, 7:16 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 3:25 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

NicolasD
January 14, 2016, 3:14 PM

I created a JUnit for that problem :
https://github.com/hibernate/hibernate-orm/pull/1219
The requests on a oneToOne property are always reduced to a query on the primary key of the owning entity. There are lots of cases where that should not be done, when optional for example.
In Hibernate documentation 3.x, the oneToOne relationships with foreign key (instead of shared primary key) were also written as oneToOne and the requests were reduced as well, which was really wrong.
The other issue, consequence of the reduction I think, is that the entities parameters are not dumped into the query, which is demonstrated by the Junit.

Vlad Mihalcea
January 17, 2018, 3:55 PM

Applied PR upstream.

Assignee

Andrea Boriero

Reporter

Martin Striz

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

backportDecision

None

Affects versions

Priority

Critical
Configure