[hibernate-issues] [JIRA] (HHH-14071) @FetchProfile not working with @OneToOne(mappedBy=...) properties

Oliver Saggau (JIRA) jira at hibernate.atlassian.net
Sun Jun 14 09:25:43 EDT 2020


Oliver Saggau ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5cf6e18898b1560e85998240 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTVmNDgzYjFjNGYzNGNkOGFhNGY2OWRmNmZlMDcyNDgiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14071?atlOrigin=eyJpIjoiYTVmNDgzYjFjNGYzNGNkOGFhNGY2OWRmNmZlMDcyNDgiLCJwIjoiaiJ9 ) HHH-14071 ( https://hibernate.atlassian.net/browse/HHH-14071?atlOrigin=eyJpIjoiYTVmNDgzYjFjNGYzNGNkOGFhNGY2OWRmNmZlMDcyNDgiLCJwIjoiaiJ9 ) @FetchProfile not working with @OneToOne(mappedBy=...) properties ( https://hibernate.atlassian.net/browse/HHH-14071?atlOrigin=eyJpIjoiYTVmNDgzYjFjNGYzNGNkOGFhNGY2OWRmNmZlMDcyNDgiLCJwIjoiaiJ9 )

Change By: Oliver Saggau ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5cf6e18898b1560e85998240 )

Sample entities:

{code :java }
@Entity
public class Address {

@Id
@GeneratedValue
private long id;

private String street;

@OneToOne(fetch = FetchType.LAZY, mappedBy = "address")
private Customer customer;

}

@Entity
public class Customer {

@Id
@GeneratedValue
private long id;

private String name;

@OneToOne(fetch = FetchType.LAZY)
private Address address;

}
{code}

When defining a {{FetchProfile}} for entity {{Address}} and association {{customer}} (which has {{mappedBy}}), the {{VerifyFetchProfileReferenceSecondPass}} will fail with the following exception:

{color: red #ff0000 }org.hibernate.MappingException: property \ [customer] not found on entity \ [org.hibernate.test.annotations.fetchprofile.Address]{color}

The problem seems to be that {{OneToOne}} associations with {{mappedBy}} are added via {{OneToOneSecondPass}} but this second pass will be added +after+ the {{VerifyFetchProfileReferenceSecondPass}} because the {{FetchProfiles}} are added quite early in the {{AnnotationBinder.bindClass}} method. I think the {{FetchProfiles}} need to be added at the end of the {{bindClass}} and/or after the {{bindClass}} has finished.

Additionally when defining {{FetchProfiles}} via package-info in the (same?) package the same exception occurs. The problem here seems to be that package-info is processed before the entity hierarchy. I think the {{bindFetchProfiles}} for all packages should be called after all entity hierarchies have been initialised.

( https://hibernate.atlassian.net/browse/HHH-14071#add-comment?atlOrigin=eyJpIjoiYTVmNDgzYjFjNGYzNGNkOGFhNGY2OWRmNmZlMDcyNDgiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14071#add-comment?atlOrigin=eyJpIjoiYTVmNDgzYjFjNGYzNGNkOGFhNGY2OWRmNmZlMDcyNDgiLCJwIjoiaiJ9 )

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#100128- sha1:14a4bff )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200614/85aa75a8/attachment.html 


More information about the hibernate-issues mailing list