0
The diary_place table is being created with 2 user_id field, I want it to be only a user_id referenced as foreign key for Diary and place tables.
I want the result to be equal to the second image.
@ManyToMany(cascade=CascadeType.ALL)
@JoinTable(name ="diary_place",
joinColumns = {
@JoinColumn(name = "diary_id", referencedColumnName="id"),
@JoinColumn(name = "d_user_id", referencedColumnName="user_id" )
},
inverseJoinColumns = {
@JoinColumn(name = "place_id", referencedColumnName="id", nullable=false),
@JoinColumn(name = "p_user_id", referencedColumnName="user_id")
},
foreignKey=@ForeignKey(name="fk_diary"),
inverseForeignKey=@ForeignKey(name="fk_place")
)
private List <Place> places;
I want it to be the same in the image I just added, only with a field referring to the user id. This way will not leave gap for inconsistency.
– Weiner
Well, that’s what I told you then. Both tables linking to the same foreign key in the middle table. If it conforms to the logic of your business, then you are correct.
– Marcelo Macedo