My question is pretty simple.
I need to model classes that are many-to-many.
case class A(
id: Pk[Long],
name: String
)
case class B(
id: Pk[Long],
name: String
)
In a game with java, you can easily code this from outside of Hibernate:
@ManyToMany(cascade=CascadeType.PERSIST)
public Set<A> allAs;
What is now the right way to play with Scala to add many, many relationships between the two classes?
Should I simulate a helper table myself as follows:
case class AToB(
a_id: Long,
b_id: Long
)
Or is there a better, simpler way without (unnecessary) code for the helper table?
source
share