문제

My question is fairly easy.

I have to model classes which are have a many-to-many relationship.

case class A(
     id: Pk[Long],
     name: String
)

case class B(
    id: Pk[Long],
    name: String
)

In play with java you can code this fairly easy, because of the Hibernate framework:

@ManyToMany(cascade=CascadeType.PERSIST)
public Set<A> allAs;

What is now the proper way in Play with Scala to add a many to many relationship between these two classes?

Do I have to model the helper table myself like this:

case class AToB(
    a_id: Long,
    b_id: Long
)

Or is there a better, easier way without the (unnecessary) code for the helper table?

도움이 되었습니까?

해결책

Since you are probably using anorm, you have to do it yourself using the powers of sql, since anorm is not an orm

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top