@JoinColumn's foreign key custom name does not work with @MapsId

Description

In the following example:

the

has ho effect but I expect the foreign key to get the custom name "fk_post". Instead the FK name is randomly generated.

The one-to-one relationship is uni-directional. The code is taken from "The best way to map a @OneToOne relationship with JPA and Hibernate" post (section "The most efficient mapping").

I also created question on SO.

Activity

Show:

Former user July 15, 2021 at 10:29 PM

Fixed in 5.3 branch as well.

Chris Cranford January 7, 2019 at 3:34 PM

, can you open a new issue and attach a reproduced test case using our test templates? Please also include a reference to this issue in the detailed description too. Thanks!

Ruslan Sheremet January 2, 2019 at 4:13 PM

It looks like I have the same issue. I'm trying to migrate to Hibernate 5.4 version but some @JoinColumn annotations don't work.
When I try to save an entity HstData, I receive an error
SqlExceptionHelper - Invalid object name 'hst_events'.
but I have an annotation @JoinColumn(name = "hst_events_id") there:

Sylvain VISSIERE GUERINET March 1, 2018 at 12:46 PM

I've got the same issue with hibernate 5.0.12 except that the attribute "name" of "@JoinColumn" was taken into account, if that can help you.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Created February 22, 2018 at 1:57 PM
Updated July 15, 2021 at 10:29 PM
Resolved July 15, 2021 at 10:27 PM