Mike Conner (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=62fe3d3...
) *commented* on HHH-16080 (
https://hibernate.atlassian.net/browse/HHH-16080?atlOrigin=eyJpIjoiZjdkZD...
)
Re: UnknownTableReferenceException with JPQL query of Entity with unidirectional OneToOne
mapping (
https://hibernate.atlassian.net/browse/HHH-16080?atlOrigin=eyJpIjoiZjdkZD...
)
@amut, It may not fail executing the query, but the results returned are incorrect. If
joining an entity without following a path – here: “thingStats” – hibernate treats it
(appropriatedly, I think) like a cross-join, and the SQL generated is:
select t1_0.THING_PK
from Thing t1_0
left join ThingStats t2_0 on true
where t2_0.THING_FK is null or t2_0.REJECTED_COUNT=0
Note the on true. However, if you add the join criteria explicitly (I changed the name to
ts2 to avoid confusion with Thing.thingStats):
select thing from Thing thing
left join ThingStats ts2 on ts2.thingPk = thing.pk
where ts2 is null or (ts2.rejectedCount = 0 and ts2.thingPk = thing.pk
It works. Here’s the generated SQL:
select t1_0.THING_PK
from Thing t1_0
left join ThingStats t2_0 on t2_0.THING_FK=t1_0.THING_PK
where t2_0.THING_FK is null or (t2_0.REJECTED_COUNT=0 and t2_0.THING_FK=t1_0.THING_PK)
But I think as a workaround, simply testing the attribute, as I indicated previously, is
simpler (and easier to understand).
(
https://hibernate.atlassian.net/browse/HHH-16080#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16080#add-comment?atlOrigin=ey...
)
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....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:634fa42 )