質問

Play2のAnorm:のフォローのようなSQLを書くことができます。

def findById(id: String): Option[Link] = DB.withConnection {implicit connection =>
  SQL("select * from links where id={id}").on('id -> id).as(simple.singleOpt)
}

それは使用しています {xxx} プレースホルダーとしてフォーマット、およびマップを指定する 'id->id. 。とにかく使用するためにありますか ? Play1で行うようにプレースホルダーとして?

私はそれを書くことができることを願っています:

def findById(id:String): Option[Link] = DB.withConnection {implicit connection =>
  SQL("select * from links where id=?").on(id).as(simple.singleOpt)
}

この形式は時々非常に便利です。

役に立ちましたか?

解決

いいえ、現在、AnormはマッピングにScalaシンボルを使用しており、「?」を使用できません。

これは将来変化する可能性がありますが、現在は不可能です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top