Reputation: 173
is there a way to have one entity (ex. Place ) bounded with another entity (ex. order ) where there are two "places" source and destination ?
example code :
@NotNull
@JoinColumn(name = "SOURCE_ID")
@ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
private Place source;
@NotNull
@JoinColumn(name = "DESTINATION_IDs")
@ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
private Place destination;
What will be on the Place entity?
Upvotes: 0
Views: 40
Reputation: 81998
This will work without a problem just like single relations. There is no difference. This includes making the relationship bidirectional, although I'm almost always skeptical about bidirectional relationships.
Upvotes: 1