In my entity, I have defined a @ManyToOne(optional = false, cascade = CascadeType.PERSIST) to my other entity. The relationship works fine.
Now I am using Postgre DB where I have created my tables and defined foreign keys between columns in my tables. In my DB, those keys work. When I use my Spring Boot application with it, Spring for some reason creates hashed foreign keys (fk1sishw42l6qx85h5f3pckl6d0) instead using the ones that I have created. At least I think, it uses those.
Hope this solution works, as it worked for me.
@ManyToOne
@JoinColumn(name="employeeID")
@ForeignKey(name='your_existing_constraint_name')
private employee employee;