Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) *commented* on HHH-16919 (
https://hibernate.atlassian.net/browse/HHH-16919?atlOrigin=eyJpIjoiMTc3Nm...
)
Re: Bidirectional mapping with @Any causes infinite loop on fetch (
https://hibernate.atlassian.net/browse/HHH-16919?atlOrigin=eyJpIjoiMTc3Nm...
)
Hello Kaushal Niraula (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) , I’m starting to investigate the problem. From early testing, looks like Hibernate
can’t detect the circularity when loading the @Any association since all loads are EAGER ,
triggering an infinite loop between the PropertyHolder and its Property backref.
A valid workaround, for the moment, would be setting the association as LAZY , i.e.
something like:
@Any(fetch = FetchType.LAZY)
@AnyKeyJavaClass( Long.class)
@AnyDiscriminator(DiscriminatorType.STRING)
@AnyDiscriminatorValues({
@AnyDiscriminatorValue(discriminator = "I" , entity =
IntegerProperty.class),
@AnyDiscriminatorValue(discriminator = "S" , entity =
StringProperty.class)
})
@Column(name = "property_type" , insertable = false , updatable = false )
@JoinColumn(name = "idtemp" , updatable = false , insertable = false )
@Cascade(CascadeType.ALL)
private Property property;
This way the load works correctly. Note that the LAZY association could be the @OneToOne
side, but in that case you would need to specify that on all entities implementing
Property.
(
https://hibernate.atlassian.net/browse/HHH-16919#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16919#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#100233- sha1:3ea1a2a )