Damien Hollis commented on Bug HHH-7446

I'm pretty sure that situations like below cause it:

Site

@ManyToOne(cascade = CascadeType.ALL, optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "DEFAULT_PAYMENT_OPTION_ID")
protected PaymentOption defaultPaymentOption;

SubSite extends Site

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "site")
@Cascade({org.hibernate.annotations.CascadeType.ALL})
private Set<PaymentOption> paymentOptions;

PaymentOption

@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "SITE_ID", nullable = true)
private Site site;

Note: PaymentOption has a reference to Site but a subclass of Site (SubSite) has the reference to PaymentOption. I think hibernate generates foreign keys for both sides but they get different names.

I don't have time to setup a test case for this but a structure like above should generate the problem.

Regardless, the test case that I did write clearly shows that the code wasn't working and that once fixed works as expected. As far as unit tests go, what I provided is better than a mapping file (for testing the code in question).

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira