val key = Set("id")
def extract(row: Row, join: Join) = new Actor(
row.bigInt("id"),
row.string("name").getOrElse("NULL")
)
val key = Set("id")
val actorRenames = Map("id" -> "actorID")
def extract(row: Row, join: Join) = {
val movieID = row.bigInt("id")
val title = row.string("title").getOrElse("NULL")
val rated = row.string("rated").getOrElse("NULL")
val actors = if (withCast) {
join.extractSeq(ActorExtractor, actorRenames)
} else {
Seq.empty
}
new Movie(movieID, title, rated, actors)
}
select * from cast JOIN movie ON movie.id = cast.movie_id JOIN actor ON actor.id = cast.actor_id WHERE movie_id= :movieID
And I get the following error:
Exception in thread "main" org.orbroker.exception.MoreThanOneException: Statement 'selectMovie' returned more than one row
Thanks for the quick rely Nils.I have used your suggestion with the following SQL query:
In think selectOne is causing the error. Doesn't it only expect a single row? I am getting more that one result back.
Here is an example of the return of the query;
+----+----------------+-------+----------+--------------+
| id | title | rated | actor_id | name |
+----+----------------+-------+----------+--------------+
| 19 | meet joe black | PG | 20 | Brad Pitt |
| 19 | meet joe black | PG | 21 | Clare Forlani |
+----+----------------+-------+----------+--------------+
Thanks,
Jeff
In think selectOne is causing the error. Doesn't it only expect a single row? I am getting more that one result back.
Here is an example of the return of the query;
+----+----------------+-------+----------+--------------+
| id | title | rated | actor_id | name |
+----+----------------+-------+----------+--------------+
| 19 | meet joe black | PG | 20 | Brad Pitt |
| 19 | meet joe black | PG | 21 | Clare Forlani |
+----+----------------+-------+----------+--------------+
broker.readOnly() { session =>
session.selectOne(Tokens.selectMovie, "movieID"-> id)
}:Option[Movie]
Have a good one,
Jeff
val movie = broker.readOnly() { session =
session.selectOne(Tokens.selectMovie, "movieID"-> id)
}:Option[Movie]
One last thought. For the use of Broker.readOnly what are the advantages of using the curried function here on the client use of the API. Only asking as the syntax is cryptic for new comers to the Scala world.
that it is curried. probably that I am new to Scala but I didn't find it easy to read and still trying to understand the benefit of curried functions as opposed to just calling it likebroker.readOnly(param1, param2)