MappingException is thrown for @JoinColumn with referencedColumnName on a @SecondaryTable - Composite Key

Description

This ticket belongs to . I think the closed ticket does not solve the problem completely but still exists for composite keys. Please see the attached test.

Attachments

4

Activity

Marco Sabato (193)January 20, 2023 at 11:32 AM

Thank you very much. Good news for the weekend.

Marco BelladelliJanuary 20, 2023 at 11:31 AM

Hi , I tested your latest example and I can confirm that my proposed solution for also fixed the problem in your latest reproducer.

I marked this issue as duplicate, you can follow the other one for updates.

Thanks for the contribution.

Marco BelladelliJanuary 19, 2023 at 8:04 AM

Ciao Marco, thank you for clearing up the example. Now both the schema and the error look a lot like .

We’re looking into that issue and your problem should be exactly the same. When we fix that I’ll try to run the new test you provided to see if that’s the case.

Keep you updated.

Marco Sabato (193)January 15, 2023 at 5:43 PM
Edited

Ciao Marco, grazie millie for for your investigation and effort.

With your explanations I was able to understand the problem. Therefore I adapted my example but I have still a problem.

I have created another example with a minimum setup to isolate my problem. This time I also used better readable names.

This is what I’m trying to achieve:

 

Here the testcase:

Here the error-output:

I guess that hibernate has to create “on c1_1.sequence=d1_0.sequence” instead.

But maybe this is also not allowed in general or I did something wrong. Would be very nice if you can have once again a look to that.

Grazie

Marco

Marco BelladelliJanuary 13, 2023 at 2:26 PM

Hello , thanks for reporting the issue and providing a reproducer!

I did some tests and looks like the problem is you’re trying to create an association to two @JoinColumns that span 2 different tables: GSBER is in the CountryEntityCompositeKey primary table (HDLNDP), while (HCSLN) is in its secondary table HDCNTP (though the mapping is a bit confusing and I might be wrong, I actually renamed all tables and columns to make sense of the example).

Joining with multiple columns that are not in the same table is not allowed and, even though the error is a bit misleading, it's not related to the @SecondaryTable key being Composite. I also tested with 5.6 to be sure and the error is the same.

Duplicate

Details

Assignee

Reporter

Affects versions

Priority

Created December 21, 2022 at 7:03 PM
Updated January 20, 2023 at 11:32 AM
Resolved January 20, 2023 at 11:29 AM