Question

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!

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top