[hibernate-issues] [JIRA] (HHH-13875) Optional one-to-one does not always join the associated entity table when querying

Gail Badner (JIRA) jira at hibernate.atlassian.net
Fri Feb 21 17:42:46 EST 2020


Gail Badner ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aabbef6b0-cce3-4556-9748-b721becb9c9a ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNTVlNGE0YzljYjE1NGYzOGI2MGU5YmNkMzQ2NmY0MDIiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13875?atlOrigin=eyJpIjoiNTVlNGE0YzljYjE1NGYzOGI2MGU5YmNkMzQ2NmY0MDIiLCJwIjoiaiJ9 ) HHH-13875 ( https://hibernate.atlassian.net/browse/HHH-13875?atlOrigin=eyJpIjoiNTVlNGE0YzljYjE1NGYzOGI2MGU5YmNkMzQ2NmY0MDIiLCJwIjoiaiJ9 ) Optional one-to-one does not always join the associated entity table when querying ( https://hibernate.atlassian.net/browse/HHH-13875?atlOrigin=eyJpIjoiNTVlNGE0YzljYjE1NGYzOGI2MGU5YmNkMzQ2NmY0MDIiLCJwIjoiaiJ9 )

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%3Aabbef6b0-cce3-4556-9748-b721becb9c9a )

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=eyJpIjoiNTVlNGE0YzljYjE1NGYzOGI2MGU5YmNkMzQ2NmY0MDIiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13875#add-comment?atlOrigin=eyJpIjoiNTVlNGE0YzljYjE1NGYzOGI2MGU5YmNkMzQ2NmY0MDIiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100121- sha1:96a3924 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200221/5f72d836/attachment.html 


More information about the hibernate-issues mailing list