1. 程式人生 > >playframework2.2.x anorm 批量插入

playframework2.2.x anorm 批量插入

definsertBatch():Unit={
  DB.withConnection { implicit connection =>
val batch = BatchSql(
      SQL("INSERT INTO books(title, author) VALUES({title}, {author})"),
       Seq(
        Seq[(String, ParameterValue[String])]("title" ->toParameterValue("Play 2 for Scala"), "author" -> toParameterValue("Peter Hilton")),
Seq[(String, ParameterValue[String])]("title" -> toParameterValue("Learning Play! Framework 2"), "author" -> toParameterValue("Andy Petrella")) )) println(batch) val res: Array[Int] = batch.execute() } }