How to Hibernate Create a Foreign Key Elegantly

Asked

Viewed 67 times

2

I’m studying Ibernate, how his technology works to create tables and fields. I noticed that when it comes to a Foreign key, it creates an unrepresentative name, which is calculated in some way.

With this, I will have no visibility when an exception or logic error occurs.

How can I create the Foreign key name in an elegant way ?

1 answer

2

One of the ways it worked this below :

@ManyToOne
@JoinColumn(name = "cur_profcodigo", referencedColumnName = "prof_codigo", foreignKey = @ForeignKey(name = "CUR_PRO_FK"))
private Professor professor;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.