From many to many relationships in a game with scala

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?

+3
source share
1 answer

Since you are probably using anorm, you need to do it yourself using sql permissions, since anorm is not orm

+6
source

All Articles