【发布时间】:2013-01-13 20:40:54
【问题描述】:
我还没有看到这样做的任何地方,但我有以下内容:
abstract class Player { val user_id: Long }
case class AlivePlayer(user_id: Long, target_id: Long) extends Player
case class DeadPlayer(user_id: Long) extends Player
def getPlayers(game: Game):Option[List[Player]] = DB.withConnection { implicit connect =>
SQL(
"""
SELECT * FROM game_participants WHERE game_id = {game_id})
"""
).on(
'game_id -> game.id
).as(Game.participantParser *)
}
在这种情况下,我收到编译器错误并显示以下消息
error: type mismatch; found : anorm.ResultSetParser[List[Product with Serializable with models.Player]] required: anorm.ResultSetParser[Option[List[models.Player]]]
).as(Game.participantParser *)
为什么我只指定返回类型为Option[List[Player]] 是不够的?
【问题讨论】:
-
你能分享
participantParser方法的定义吗?
标签: scala playframework-2.0 anorm playframework-2.1