Brett Meyer commented on Bug HHH-2872

Test case pushed: https://github.com/hibernate/hibernate-orm/commit/4d461cc44ebe0f017c6a79471e8e8f77c48450fc

Strong Liu, I might need a bit of help after all.

In ProductDetails, change

    @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
    @JoinColumns({ @JoinColumn(name = "id_product", referencedColumnName = "id_product", nullable = false),
            @JoinColumn(name = "id_product_version", referencedColumnName = "id_product_version", nullable = false) })
    private Product product;

to

    @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
    @JoinColumn(name = "id_product_version", referencedColumnName = "id_product_version", nullable = false)
    private Product product;

, the "id_product_version" logical name is bound for the product table first, then product_details (as it should be).

The FkSecondPass correctly has both Columns if the @JoinColumns is left in place. So, I believe that's bound correctly.

I'm having trouble understanding if the problem is in:

  • Configuration#processFkSecondPassInOrder (as you mentioned, sp.isInPrimaryKey is false for all these cases)
  • ToOneFkSecondPass#doSecondPass -> BinderHelper#createSyntheticPropertyReference -> Ejb3JoinColumn#checkReferencedColumnsType()
  • The order in which FkSecondPasses are created
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