문제

Let's say, we have a 1-m relationship, the classical example: Author-Book. We have 2 case classes (and the tables in the DB ofc) in the data access layer, Author and Book correspondingly.

Is there any way to get the collection of authors, having each of them populated by the collection of authored books in Anorm?

If there is no way, what is the correct (the best) way to get this collections linked, after execution of 2 queries, like "SELECT * FROM Author" and "SELECT * FROM Book", assuming we have a foregn-key relationship?

Thanks!

도움이 되었습니까?

해결책

Had you take a look at the "computer-database" from the Play samples ?

In this example, you can see that a Company owns many Computers: https://github.com/playframework/Play20/blob/master/samples/scala/computer-database/app/models/Models.scala#L84

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