سؤال

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