Hi want to create a foreign key association/constraint but only map the primary key, not the entire entity. So what I want to achieve is something like this (which creates the correct db schema but fails on save):
@Entity(name = "journal")
public class JournalEntry {
@Id
private UUID id;
@ManyToOne(targetEntity = User.class, optional=false)
@JoinColumn(name="id")
private UUID userId;
@Column
private String text
}
In case the above is not possible, how can I manually specify that a foreign key constraint should be created?
This question did get asked quite a lot a few years ago but there was never a satisfactory answer and I thought maybe something changed in the last 8-12 years.