Reputation: 571
I would like to have access to related Many-to-many table, as well as to the join table.
That's how this is going to look in database:
So, let's say I would like to have access from "X" to "Y" and "Z".
Is it ok, to simply add "Z" with @ManyToMany
, and "Y" with @OneToMany
annotation?
Right now it is purely theoretical question, I'm just designing this app, and this looks kinda strange, so I would like to know if it is common and correct way to to that.
Upvotes: 0
Views: 253
Reputation: 2224
If you want to model your join table you can use ManyToOne
on the join table when referring to X
or Z
and OneToMany
on the side of X
and Z
. You would use ManyToMany
when you don't want to model the join table.
Upvotes: 1