Wrong parameter binding when joining in a key that is not the @id/PK

Description

The problem happens when you have an entity (B) that has a FK/@JoinColumn that points to a unique key of another entity (A) and this unique key is not the PK/@id of A.

when I run this:

Hibernate generates the correct SQL:

Notice that the join is correctly made on the unique key, not the @id key. The error is in the binding. Instead of binding the id of the argument to the id column, it binds the unique key value of the argument to the id column.

Check the test case, it's very simple and you will understand what I'm trying to say here. The line above will only make sense if you look at the example.

Environment

None

Assignee

Unassigned

Reporter

GustavoA

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure