In JPA/Hibernate, is it possible to express a foreign key without adding a relationship?
In DDD in aggregate root I would like to have an id of other aggregate root - I don't want to have a reference to this aggregate, only id. Is it possible to enforce foreign key by hibernate? (I use hibernate auto schema generation).
EG
@Entity
Person {
...
}
@Entity
Event {
@Id
private long eventId;
@ForeignKey(references Person.id)
private long personId;
// I don't want to map it as @ManyToOne Person
}
I don't want to use @ManyToOne, because I don't want to store a reference to other aggregate in Event aggregate. It would be DDD antipattern.