Gail Badner (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNTVlNGE0Yzlj...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-13875?atlOrigin=eyJpIjoiNTVlNG...
) HHH-13875 (
https://hibernate.atlassian.net/browse/HHH-13875?atlOrigin=eyJpIjoiNTVlNG...
) Optional one-to-one does not always join the associated entity table when querying (
https://hibernate.atlassian.net/browse/HHH-13875?atlOrigin=eyJpIjoiNTVlNG...
)
Issue Type: Bug Affects Versions: 5.4.12 Assignee: Unassigned Created: 21/Feb/2020 14:42
PM Fix Versions: 5.4.13 Priority: Major Reporter: Gail Badner (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Using the following entities:
@Entity
public class Foo
{
@Id
private Long id;
@OneToOne(optional = true )
@MapsId
@JoinColumn(name = "id" )
@NotFound(action = NotFoundAction.IGNORE)
private Bar bar;
}
@Entity
public class Bar {
@Id
private long barId;
}
If there exists a Foo entity, but there is no Bar entity with the same ID value as the Foo
entity, then the following query, "from Foo where bar.id = ?1" , should return
null.
Instead, the query returns a Foo object with property bar set to null. This happens
because the generated SQL does not include a join to the Bar entity table, as it should.
Notice that the query uses the "generic" ID named "id" , not the
actual ID ( barId ).
(
https://hibernate.atlassian.net/browse/HHH-13875#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-13875#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#100121- sha1:96a3924 )