The default name Hibernate JoinColumn is missing '_id'

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn (name = "account_id")
private Account account;

It works great.

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
private Account account;

Results in: Exception : Missing column account in SomeSchema.SomeOwnerTable

JPA Spec says default union column name

property name ( 'account') + '_' + target table primary key ( 'id' )

But it looks like hibernate is only looking for a property named "account" instead of "account_id".

Any comments?

+3
source share
1 answer

I think you can safely get rid of the annotation @JoinColumn- in any case there is a connection column.

Also, make sure that you have not set up a specific naming strategy that can override the default behavior.

+4
source

Source: https://habr.com/ru/post/1525855/


All Articles